vue.js 125 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772
  1. /*
  2. Vue.js v0.10.6
  3. (c) 2014 Evan You
  4. License: MIT
  5. */
  6. ;(function(){
  7. 'use strict';
  8. /**
  9. * Require the given path.
  10. *
  11. * @param {String} path
  12. * @return {Object} exports
  13. * @api public
  14. */
  15. function require(path, parent, orig) {
  16. var resolved = require.resolve(path);
  17. // lookup failed
  18. if (null == resolved) {
  19. throwError()
  20. return
  21. }
  22. var module = require.modules[resolved];
  23. // perform real require()
  24. // by invoking the module's
  25. // registered function
  26. if (!module._resolving && !module.exports) {
  27. var mod = {};
  28. mod.exports = {};
  29. mod.client = mod.component = true;
  30. module._resolving = true;
  31. module.call(this, mod.exports, require.relative(resolved), mod);
  32. delete module._resolving;
  33. module.exports = mod.exports;
  34. }
  35. function throwError () {
  36. orig = orig || path;
  37. parent = parent || 'root';
  38. var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
  39. err.path = orig;
  40. err.parent = parent;
  41. err.require = true;
  42. throw err;
  43. }
  44. return module.exports;
  45. }
  46. /**
  47. * Registered modules.
  48. */
  49. require.modules = {};
  50. /**
  51. * Registered aliases.
  52. */
  53. require.aliases = {};
  54. /**
  55. * Resolve `path`.
  56. *
  57. * Lookup:
  58. *
  59. * - PATH/index.js
  60. * - PATH.js
  61. * - PATH
  62. *
  63. * @param {String} path
  64. * @return {String} path or null
  65. * @api private
  66. */
  67. require.exts = [
  68. '',
  69. '.js',
  70. '.json',
  71. '/index.js',
  72. '/index.json'
  73. ];
  74. require.resolve = function(path) {
  75. if (path.charAt(0) === '/') path = path.slice(1);
  76. for (var i = 0; i < 5; i++) {
  77. var fullPath = path + require.exts[i];
  78. if (require.modules.hasOwnProperty(fullPath)) return fullPath;
  79. if (require.aliases.hasOwnProperty(fullPath)) return require.aliases[fullPath];
  80. }
  81. };
  82. /**
  83. * Normalize `path` relative to the current path.
  84. *
  85. * @param {String} curr
  86. * @param {String} path
  87. * @return {String}
  88. * @api private
  89. */
  90. require.normalize = function(curr, path) {
  91. var segs = [];
  92. if ('.' != path.charAt(0)) return path;
  93. curr = curr.split('/');
  94. path = path.split('/');
  95. for (var i = 0; i < path.length; ++i) {
  96. if ('..' === path[i]) {
  97. curr.pop();
  98. } else if ('.' != path[i] && '' != path[i]) {
  99. segs.push(path[i]);
  100. }
  101. }
  102. return curr.concat(segs).join('/');
  103. };
  104. /**
  105. * Register module at `path` with callback `definition`.
  106. *
  107. * @param {String} path
  108. * @param {Function} definition
  109. * @api private
  110. */
  111. require.register = function(path, definition) {
  112. require.modules[path] = definition;
  113. };
  114. /**
  115. * Alias a module definition.
  116. *
  117. * @param {String} from
  118. * @param {String} to
  119. * @api private
  120. */
  121. require.alias = function(from, to) {
  122. if (!require.modules.hasOwnProperty(from)) {
  123. throwError()
  124. return
  125. }
  126. require.aliases[to] = from;
  127. function throwError () {
  128. throw new Error('Failed to alias "' + from + '", it does not exist');
  129. }
  130. };
  131. /**
  132. * Return a require function relative to the `parent` path.
  133. *
  134. * @param {String} parent
  135. * @return {Function}
  136. * @api private
  137. */
  138. require.relative = function(parent) {
  139. var p = require.normalize(parent, '..');
  140. /**
  141. * The relative require() itself.
  142. */
  143. function localRequire(path) {
  144. var resolved = localRequire.resolve(path);
  145. return require(resolved, parent, path);
  146. }
  147. /**
  148. * Resolve relative to the parent.
  149. */
  150. localRequire.resolve = function(path) {
  151. var c = path.charAt(0);
  152. if ('/' === c) return path.slice(1);
  153. if ('.' === c) return require.normalize(p, path);
  154. // resolve deps by returning
  155. // the dep in the nearest "deps"
  156. // directory
  157. var segs = parent.split('/');
  158. var i = segs.length;
  159. while (i--) {
  160. if (segs[i] === 'deps') {
  161. break;
  162. }
  163. }
  164. path = segs.slice(0, i + 2).join('/') + '/deps/' + path;
  165. return path;
  166. };
  167. /**
  168. * Check if module is defined at `path`.
  169. */
  170. localRequire.exists = function(path) {
  171. return require.modules.hasOwnProperty(localRequire.resolve(path));
  172. };
  173. return localRequire;
  174. };
  175. require.register("vue/src/main.js", function(exports, require, module){
  176. var config = require('./config'),
  177. ViewModel = require('./viewmodel'),
  178. utils = require('./utils'),
  179. makeHash = utils.hash,
  180. assetTypes = ['directive', 'filter', 'partial', 'effect', 'component'],
  181. // Internal modules that are exposed for plugins
  182. pluginAPI = {
  183. utils: utils,
  184. config: config,
  185. transition: require('./transition'),
  186. observer: require('./observer')
  187. }
  188. ViewModel.options = config.globalAssets = {
  189. directives : require('./directives'),
  190. filters : require('./filters'),
  191. partials : makeHash(),
  192. effects : makeHash(),
  193. components : makeHash()
  194. }
  195. /**
  196. * Expose asset registration methods
  197. */
  198. assetTypes.forEach(function (type) {
  199. ViewModel[type] = function (id, value) {
  200. var hash = this.options[type + 's']
  201. if (!hash) {
  202. hash = this.options[type + 's'] = makeHash()
  203. }
  204. if (!value) return hash[id]
  205. if (type === 'partial') {
  206. value = utils.parseTemplateOption(value)
  207. } else if (type === 'component') {
  208. value = utils.toConstructor(value)
  209. } else if (type === 'filter') {
  210. utils.checkFilter(value)
  211. }
  212. hash[id] = value
  213. return this
  214. }
  215. })
  216. /**
  217. * Set config options
  218. */
  219. ViewModel.config = function (opts, val) {
  220. if (typeof opts === 'string') {
  221. if (val === undefined) {
  222. return config[opts]
  223. } else {
  224. config[opts] = val
  225. }
  226. } else {
  227. utils.extend(config, opts)
  228. }
  229. return this
  230. }
  231. /**
  232. * Expose an interface for plugins
  233. */
  234. ViewModel.use = function (plugin) {
  235. if (typeof plugin === 'string') {
  236. try {
  237. plugin = require(plugin)
  238. } catch (e) {
  239. utils.warn('Cannot find plugin: ' + plugin)
  240. return
  241. }
  242. }
  243. // additional parameters
  244. var args = [].slice.call(arguments, 1)
  245. args.unshift(this)
  246. if (typeof plugin.install === 'function') {
  247. plugin.install.apply(plugin, args)
  248. } else {
  249. plugin.apply(null, args)
  250. }
  251. return this
  252. }
  253. /**
  254. * Expose internal modules for plugins
  255. */
  256. ViewModel.require = function (module) {
  257. return pluginAPI[module]
  258. }
  259. ViewModel.extend = extend
  260. ViewModel.nextTick = utils.nextTick
  261. /**
  262. * Expose the main ViewModel class
  263. * and add extend method
  264. */
  265. function extend (options) {
  266. var ParentVM = this
  267. // extend data options need to be copied
  268. // on instantiation
  269. if (options.data) {
  270. options.defaultData = options.data
  271. delete options.data
  272. }
  273. // inherit options
  274. // but only when the super class is not the native Vue.
  275. if (ParentVM !== ViewModel) {
  276. options = inheritOptions(options, ParentVM.options, true)
  277. }
  278. utils.processOptions(options)
  279. var ExtendedVM = function (opts, asParent) {
  280. if (!asParent) {
  281. opts = inheritOptions(opts, options, true)
  282. }
  283. ParentVM.call(this, opts, true)
  284. }
  285. // inherit prototype props
  286. var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype)
  287. utils.defProtected(proto, 'constructor', ExtendedVM)
  288. // allow extended VM to be further extended
  289. ExtendedVM.extend = extend
  290. ExtendedVM.super = ParentVM
  291. ExtendedVM.options = options
  292. // allow extended VM to add its own assets
  293. assetTypes.forEach(function (type) {
  294. ExtendedVM[type] = ViewModel[type]
  295. })
  296. // allow extended VM to use plugins
  297. ExtendedVM.use = ViewModel.use
  298. ExtendedVM.require = ViewModel.require
  299. return ExtendedVM
  300. }
  301. /**
  302. * Inherit options
  303. *
  304. * For options such as `data`, `vms`, `directives`, 'partials',
  305. * they should be further extended. However extending should only
  306. * be done at top level.
  307. *
  308. * `proto` is an exception because it's handled directly on the
  309. * prototype.
  310. *
  311. * `el` is an exception because it's not allowed as an
  312. * extension option, but only as an instance option.
  313. */
  314. function inheritOptions (child, parent, topLevel) {
  315. child = child || {}
  316. if (!parent) return child
  317. for (var key in parent) {
  318. if (key === 'el') continue
  319. var val = child[key],
  320. parentVal = parent[key]
  321. if (topLevel && typeof val === 'function' && parentVal) {
  322. // merge hook functions into an array
  323. child[key] = [val]
  324. if (Array.isArray(parentVal)) {
  325. child[key] = child[key].concat(parentVal)
  326. } else {
  327. child[key].push(parentVal)
  328. }
  329. } else if (
  330. topLevel &&
  331. (utils.isTrueObject(val) || utils.isTrueObject(parentVal))
  332. && !(parentVal instanceof ViewModel)
  333. ) {
  334. // merge toplevel object options
  335. child[key] = inheritOptions(val, parentVal)
  336. } else if (val === undefined) {
  337. // inherit if child doesn't override
  338. child[key] = parentVal
  339. }
  340. }
  341. return child
  342. }
  343. module.exports = ViewModel
  344. });
  345. require.register("vue/src/emitter.js", function(exports, require, module){
  346. var slice = [].slice
  347. function Emitter (ctx) {
  348. this._ctx = ctx || this
  349. }
  350. var EmitterProto = Emitter.prototype
  351. EmitterProto.on = function (event, fn) {
  352. this._cbs = this._cbs || {}
  353. ;(this._cbs[event] = this._cbs[event] || [])
  354. .push(fn)
  355. return this
  356. }
  357. EmitterProto.once = function (event, fn) {
  358. var self = this
  359. this._cbs = this._cbs || {}
  360. function on () {
  361. self.off(event, on)
  362. fn.apply(this, arguments)
  363. }
  364. on.fn = fn
  365. this.on(event, on)
  366. return this
  367. }
  368. EmitterProto.off = function (event, fn) {
  369. this._cbs = this._cbs || {}
  370. // all
  371. if (!arguments.length) {
  372. this._cbs = {}
  373. return this
  374. }
  375. // specific event
  376. var callbacks = this._cbs[event]
  377. if (!callbacks) return this
  378. // remove all handlers
  379. if (arguments.length === 1) {
  380. delete this._cbs[event]
  381. return this
  382. }
  383. // remove specific handler
  384. var cb
  385. for (var i = 0; i < callbacks.length; i++) {
  386. cb = callbacks[i]
  387. if (cb === fn || cb.fn === fn) {
  388. callbacks.splice(i, 1)
  389. break
  390. }
  391. }
  392. return this
  393. }
  394. /**
  395. * The internal, faster emit with fixed amount of arguments
  396. * using Function.call
  397. */
  398. EmitterProto.emit = function (event, a, b, c) {
  399. this._cbs = this._cbs || {}
  400. var callbacks = this._cbs[event]
  401. if (callbacks) {
  402. callbacks = callbacks.slice(0)
  403. for (var i = 0, len = callbacks.length; i < len; i++) {
  404. callbacks[i].call(this._ctx, a, b, c)
  405. }
  406. }
  407. return this
  408. }
  409. /**
  410. * The external emit using Function.apply
  411. */
  412. EmitterProto.applyEmit = function (event) {
  413. this._cbs = this._cbs || {}
  414. var callbacks = this._cbs[event], args
  415. if (callbacks) {
  416. callbacks = callbacks.slice(0)
  417. args = slice.call(arguments, 1)
  418. for (var i = 0, len = callbacks.length; i < len; i++) {
  419. callbacks[i].apply(this._ctx, args)
  420. }
  421. }
  422. return this
  423. }
  424. module.exports = Emitter
  425. });
  426. require.register("vue/src/config.js", function(exports, require, module){
  427. var TextParser = require('./text-parser')
  428. module.exports = {
  429. prefix : 'v',
  430. debug : false,
  431. silent : false,
  432. enterClass : 'v-enter',
  433. leaveClass : 'v-leave',
  434. interpolate : true
  435. }
  436. Object.defineProperty(module.exports, 'delimiters', {
  437. get: function () {
  438. return TextParser.delimiters
  439. },
  440. set: function (delimiters) {
  441. TextParser.setDelimiters(delimiters)
  442. }
  443. })
  444. });
  445. require.register("vue/src/utils.js", function(exports, require, module){
  446. var config = require('./config'),
  447. toString = ({}).toString,
  448. win = window,
  449. console = win.console,
  450. def = Object.defineProperty,
  451. OBJECT = 'object',
  452. THIS_RE = /[^\w]this[^\w]/,
  453. BRACKET_RE_S = /\['([^']+)'\]/g,
  454. BRACKET_RE_D = /\["([^"]+)"\]/g,
  455. hasClassList = 'classList' in document.documentElement,
  456. ViewModel // late def
  457. var defer =
  458. win.requestAnimationFrame ||
  459. win.webkitRequestAnimationFrame ||
  460. win.setTimeout
  461. /**
  462. * Normalize keypath with possible brackets into dot notations
  463. */
  464. function normalizeKeypath (key) {
  465. return key.indexOf('[') < 0
  466. ? key
  467. : key.replace(BRACKET_RE_S, '.$1')
  468. .replace(BRACKET_RE_D, '.$1')
  469. }
  470. var utils = module.exports = {
  471. /**
  472. * Convert a string template to a dom fragment
  473. */
  474. toFragment: require('./fragment'),
  475. /**
  476. * Parse the various types of template options
  477. */
  478. parseTemplateOption: require('./template-parser.js'),
  479. /**
  480. * get a value from an object keypath
  481. */
  482. get: function (obj, key) {
  483. /* jshint eqeqeq: false */
  484. key = normalizeKeypath(key)
  485. if (key.indexOf('.') < 0) {
  486. return obj[key]
  487. }
  488. var path = key.split('.'),
  489. d = -1, l = path.length
  490. while (++d < l && obj != null) {
  491. obj = obj[path[d]]
  492. }
  493. return obj
  494. },
  495. /**
  496. * set a value to an object keypath
  497. */
  498. set: function (obj, key, val) {
  499. /* jshint eqeqeq: false */
  500. key = normalizeKeypath(key)
  501. if (key.indexOf('.') < 0) {
  502. obj[key] = val
  503. return
  504. }
  505. var path = key.split('.'),
  506. d = -1, l = path.length - 1
  507. while (++d < l) {
  508. if (obj[path[d]] == null) {
  509. obj[path[d]] = {}
  510. }
  511. obj = obj[path[d]]
  512. }
  513. obj[path[d]] = val
  514. },
  515. /**
  516. * return the base segment of a keypath
  517. */
  518. baseKey: function (key) {
  519. return key.indexOf('.') > 0
  520. ? key.split('.')[0]
  521. : key
  522. },
  523. /**
  524. * Create a prototype-less object
  525. * which is a better hash/map
  526. */
  527. hash: function () {
  528. return Object.create(null)
  529. },
  530. /**
  531. * get an attribute and remove it.
  532. */
  533. attr: function (el, type) {
  534. var attr = config.prefix + '-' + type,
  535. val = el.getAttribute(attr)
  536. if (val !== null) {
  537. el.removeAttribute(attr)
  538. }
  539. return val
  540. },
  541. /**
  542. * Define an ienumerable property
  543. * This avoids it being included in JSON.stringify
  544. * or for...in loops.
  545. */
  546. defProtected: function (obj, key, val, enumerable, writable) {
  547. def(obj, key, {
  548. value : val,
  549. enumerable : enumerable,
  550. writable : writable,
  551. configurable : true
  552. })
  553. },
  554. /**
  555. * A less bullet-proof but more efficient type check
  556. * than Object.prototype.toString
  557. */
  558. isObject: function (obj) {
  559. return typeof obj === OBJECT && obj && !Array.isArray(obj)
  560. },
  561. /**
  562. * A more accurate but less efficient type check
  563. */
  564. isTrueObject: function (obj) {
  565. return toString.call(obj) === '[object Object]'
  566. },
  567. /**
  568. * Most simple bind
  569. * enough for the usecase and fast than native bind()
  570. */
  571. bind: function (fn, ctx) {
  572. return function (arg) {
  573. return fn.call(ctx, arg)
  574. }
  575. },
  576. /**
  577. * Make sure null and undefined output empty string
  578. */
  579. guard: function (value) {
  580. /* jshint eqeqeq: false, eqnull: true */
  581. return value == null
  582. ? ''
  583. : (typeof value == 'object')
  584. ? JSON.stringify(value)
  585. : value
  586. },
  587. /**
  588. * When setting value on the VM, parse possible numbers
  589. */
  590. checkNumber: function (value) {
  591. return (isNaN(value) || value === null || typeof value === 'boolean')
  592. ? value
  593. : Number(value)
  594. },
  595. /**
  596. * simple extend
  597. */
  598. extend: function (obj, ext) {
  599. for (var key in ext) {
  600. if (obj[key] !== ext[key]) {
  601. obj[key] = ext[key]
  602. }
  603. }
  604. return obj
  605. },
  606. /**
  607. * filter an array with duplicates into uniques
  608. */
  609. unique: function (arr) {
  610. var hash = utils.hash(),
  611. i = arr.length,
  612. key, res = []
  613. while (i--) {
  614. key = arr[i]
  615. if (hash[key]) continue
  616. hash[key] = 1
  617. res.push(key)
  618. }
  619. return res
  620. },
  621. /**
  622. * Convert the object to a ViewModel constructor
  623. * if it is not already one
  624. */
  625. toConstructor: function (obj) {
  626. ViewModel = ViewModel || require('./viewmodel')
  627. return utils.isObject(obj)
  628. ? ViewModel.extend(obj)
  629. : typeof obj === 'function'
  630. ? obj
  631. : null
  632. },
  633. /**
  634. * Check if a filter function contains references to `this`
  635. * If yes, mark it as a computed filter.
  636. */
  637. checkFilter: function (filter) {
  638. if (THIS_RE.test(filter.toString())) {
  639. filter.computed = true
  640. }
  641. },
  642. /**
  643. * convert certain option values to the desired format.
  644. */
  645. processOptions: function (options) {
  646. var components = options.components,
  647. partials = options.partials,
  648. template = options.template,
  649. filters = options.filters,
  650. key
  651. if (components) {
  652. for (key in components) {
  653. components[key] = utils.toConstructor(components[key])
  654. }
  655. }
  656. if (partials) {
  657. for (key in partials) {
  658. partials[key] = utils.parseTemplateOption(partials[key])
  659. }
  660. }
  661. if (filters) {
  662. for (key in filters) {
  663. utils.checkFilter(filters[key])
  664. }
  665. }
  666. if (template) {
  667. options.template = utils.parseTemplateOption(template)
  668. }
  669. },
  670. /**
  671. * used to defer batch updates
  672. */
  673. nextTick: function (cb) {
  674. defer(cb, 0)
  675. },
  676. /**
  677. * add class for IE9
  678. * uses classList if available
  679. */
  680. addClass: function (el, cls) {
  681. if (hasClassList) {
  682. el.classList.add(cls)
  683. } else {
  684. var cur = ' ' + el.className + ' '
  685. if (cur.indexOf(' ' + cls + ' ') < 0) {
  686. el.className = (cur + cls).trim()
  687. }
  688. }
  689. },
  690. /**
  691. * remove class for IE9
  692. */
  693. removeClass: function (el, cls) {
  694. if (hasClassList) {
  695. el.classList.remove(cls)
  696. } else {
  697. var cur = ' ' + el.className + ' ',
  698. tar = ' ' + cls + ' '
  699. while (cur.indexOf(tar) >= 0) {
  700. cur = cur.replace(tar, ' ')
  701. }
  702. el.className = cur.trim()
  703. }
  704. },
  705. /**
  706. * Convert an object to Array
  707. * used in v-repeat and array filters
  708. */
  709. objectToArray: function (obj) {
  710. var res = [], val, data
  711. for (var key in obj) {
  712. val = obj[key]
  713. data = utils.isObject(val)
  714. ? val
  715. : { $value: val }
  716. data.$key = key
  717. res.push(data)
  718. }
  719. return res
  720. }
  721. }
  722. enableDebug()
  723. function enableDebug () {
  724. /**
  725. * log for debugging
  726. */
  727. utils.log = function (msg) {
  728. if (config.debug && console) {
  729. console.log(msg)
  730. }
  731. }
  732. /**
  733. * warnings, traces by default
  734. * can be suppressed by `silent` option.
  735. */
  736. utils.warn = function (msg) {
  737. if (!config.silent && console) {
  738. console.warn(msg)
  739. if (config.debug && console.trace) {
  740. console.trace()
  741. }
  742. }
  743. }
  744. }
  745. });
  746. require.register("vue/src/fragment.js", function(exports, require, module){
  747. // string -> DOM conversion
  748. // wrappers originally from jQuery, scooped from component/domify
  749. var map = {
  750. legend : [1, '<fieldset>', '</fieldset>'],
  751. tr : [2, '<table><tbody>', '</tbody></table>'],
  752. col : [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
  753. _default : [0, '', '']
  754. }
  755. map.td =
  756. map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']
  757. map.option =
  758. map.optgroup = [1, '<select multiple="multiple">', '</select>']
  759. map.thead =
  760. map.tbody =
  761. map.colgroup =
  762. map.caption =
  763. map.tfoot = [1, '<table>', '</table>']
  764. map.text =
  765. map.circle =
  766. map.ellipse =
  767. map.line =
  768. map.path =
  769. map.polygon =
  770. map.polyline =
  771. map.rect = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']
  772. var TAG_RE = /<([\w:]+)/
  773. module.exports = function (templateString) {
  774. var frag = document.createDocumentFragment(),
  775. m = TAG_RE.exec(templateString)
  776. // text only
  777. if (!m) {
  778. frag.appendChild(document.createTextNode(templateString))
  779. return frag
  780. }
  781. var tag = m[1],
  782. wrap = map[tag] || map._default,
  783. depth = wrap[0],
  784. prefix = wrap[1],
  785. suffix = wrap[2],
  786. node = document.createElement('div')
  787. node.innerHTML = prefix + templateString.trim() + suffix
  788. while (depth--) node = node.lastChild
  789. // one element
  790. if (node.firstChild === node.lastChild) {
  791. frag.appendChild(node.firstChild)
  792. return frag
  793. }
  794. // multiple nodes, return a fragment
  795. var child
  796. /* jshint boss: true */
  797. while (child = node.firstChild) {
  798. if (node.nodeType === 1) {
  799. frag.appendChild(child)
  800. }
  801. }
  802. return frag
  803. }
  804. });
  805. require.register("vue/src/compiler.js", function(exports, require, module){
  806. var Emitter = require('./emitter'),
  807. Observer = require('./observer'),
  808. config = require('./config'),
  809. utils = require('./utils'),
  810. Binding = require('./binding'),
  811. Directive = require('./directive'),
  812. TextParser = require('./text-parser'),
  813. DepsParser = require('./deps-parser'),
  814. ExpParser = require('./exp-parser'),
  815. ViewModel,
  816. // cache methods
  817. slice = [].slice,
  818. extend = utils.extend,
  819. hasOwn = ({}).hasOwnProperty,
  820. def = Object.defineProperty,
  821. // hooks to register
  822. hooks = [
  823. 'created', 'ready',
  824. 'beforeDestroy', 'afterDestroy',
  825. 'attached', 'detached'
  826. ],
  827. // list of priority directives
  828. // that needs to be checked in specific order
  829. priorityDirectives = [
  830. 'if',
  831. 'repeat',
  832. 'view',
  833. 'component'
  834. ]
  835. /**
  836. * The DOM compiler
  837. * scans a DOM node and compile bindings for a ViewModel
  838. */
  839. function Compiler (vm, options) {
  840. var compiler = this,
  841. key, i
  842. // default state
  843. compiler.init = true
  844. compiler.destroyed = false
  845. // process and extend options
  846. options = compiler.options = options || {}
  847. utils.processOptions(options)
  848. // copy compiler options
  849. extend(compiler, options.compilerOptions)
  850. // repeat indicates this is a v-repeat instance
  851. compiler.repeat = compiler.repeat || false
  852. // expCache will be shared between v-repeat instances
  853. compiler.expCache = compiler.expCache || {}
  854. // initialize element
  855. var el = compiler.el = compiler.setupElement(options)
  856. utils.log('\nnew VM instance: ' + el.tagName + '\n')
  857. // set other compiler properties
  858. compiler.vm = el.vue_vm = vm
  859. compiler.bindings = utils.hash()
  860. compiler.dirs = []
  861. compiler.deferred = []
  862. compiler.computed = []
  863. compiler.children = []
  864. compiler.emitter = new Emitter(vm)
  865. // VM ---------------------------------------------------------------------
  866. // set VM properties
  867. vm.$ = {}
  868. vm.$el = el
  869. vm.$options = options
  870. vm.$compiler = compiler
  871. vm.$event = null
  872. // set parent & root
  873. var parentVM = options.parent
  874. if (parentVM) {
  875. compiler.parent = parentVM.$compiler
  876. parentVM.$compiler.children.push(compiler)
  877. vm.$parent = parentVM
  878. // inherit lazy option
  879. if (!('lazy' in options)) {
  880. options.lazy = compiler.parent.options.lazy
  881. }
  882. }
  883. vm.$root = getRoot(compiler).vm
  884. // DATA -------------------------------------------------------------------
  885. // setup observer
  886. // this is necesarry for all hooks and data observation events
  887. compiler.setupObserver()
  888. // create bindings for computed properties
  889. if (options.methods) {
  890. for (key in options.methods) {
  891. compiler.createBinding(key)
  892. }
  893. }
  894. // create bindings for methods
  895. if (options.computed) {
  896. for (key in options.computed) {
  897. compiler.createBinding(key)
  898. }
  899. }
  900. // initialize data
  901. var data = compiler.data = options.data || {},
  902. defaultData = options.defaultData
  903. if (defaultData) {
  904. for (key in defaultData) {
  905. if (!hasOwn.call(data, key)) {
  906. data[key] = defaultData[key]
  907. }
  908. }
  909. }
  910. // copy paramAttributes
  911. var params = options.paramAttributes
  912. if (params) {
  913. i = params.length
  914. while (i--) {
  915. data[params[i]] = utils.checkNumber(
  916. compiler.eval(
  917. el.getAttribute(params[i])
  918. )
  919. )
  920. }
  921. }
  922. // copy data properties to vm
  923. // so user can access them in the created hook
  924. extend(vm, data)
  925. vm.$data = data
  926. // beforeCompile hook
  927. compiler.execHook('created')
  928. // the user might have swapped the data ...
  929. data = compiler.data = vm.$data
  930. // user might also set some properties on the vm
  931. // in which case we should copy back to $data
  932. var vmProp
  933. for (key in vm) {
  934. vmProp = vm[key]
  935. if (
  936. key.charAt(0) !== '$' &&
  937. data[key] !== vmProp &&
  938. typeof vmProp !== 'function'
  939. ) {
  940. data[key] = vmProp
  941. }
  942. }
  943. // now we can observe the data.
  944. // this will convert data properties to getter/setters
  945. // and emit the first batch of set events, which will
  946. // in turn create the corresponding bindings.
  947. compiler.observeData(data)
  948. // COMPILE ----------------------------------------------------------------
  949. // before compiling, resolve content insertion points
  950. if (options.template) {
  951. this.resolveContent()
  952. }
  953. // now parse the DOM and bind directives.
  954. // During this stage, we will also create bindings for
  955. // encountered keypaths that don't have a binding yet.
  956. compiler.compile(el, true)
  957. // Any directive that creates child VMs are deferred
  958. // so that when they are compiled, all bindings on the
  959. // parent VM have been created.
  960. i = compiler.deferred.length
  961. while (i--) {
  962. compiler.bindDirective(compiler.deferred[i])
  963. }
  964. compiler.deferred = null
  965. // extract dependencies for computed properties.
  966. // this will evaluated all collected computed bindings
  967. // and collect get events that are emitted.
  968. if (this.computed.length) {
  969. DepsParser.parse(this.computed)
  970. }
  971. // done!
  972. compiler.init = false
  973. // post compile / ready hook
  974. compiler.execHook('ready')
  975. }
  976. var CompilerProto = Compiler.prototype
  977. /**
  978. * Initialize the VM/Compiler's element.
  979. * Fill it in with the template if necessary.
  980. */
  981. CompilerProto.setupElement = function (options) {
  982. // create the node first
  983. var el = typeof options.el === 'string'
  984. ? document.querySelector(options.el)
  985. : options.el || document.createElement(options.tagName || 'div')
  986. var template = options.template,
  987. child, replacer, i, attr, attrs
  988. if (template) {
  989. // collect anything already in there
  990. if (el.hasChildNodes()) {
  991. this.rawContent = document.createElement('div')
  992. /* jshint boss: true */
  993. while (child = el.firstChild) {
  994. this.rawContent.appendChild(child)
  995. }
  996. }
  997. // replace option: use the first node in
  998. // the template directly
  999. if (options.replace && template.firstChild === template.lastChild) {
  1000. replacer = template.firstChild.cloneNode(true)
  1001. if (el.parentNode) {
  1002. el.parentNode.insertBefore(replacer, el)
  1003. el.parentNode.removeChild(el)
  1004. }
  1005. // copy over attributes
  1006. if (el.hasAttributes()) {
  1007. i = el.attributes.length
  1008. while (i--) {
  1009. attr = el.attributes[i]
  1010. replacer.setAttribute(attr.name, attr.value)
  1011. }
  1012. }
  1013. // replace
  1014. el = replacer
  1015. } else {
  1016. el.appendChild(template.cloneNode(true))
  1017. }
  1018. }
  1019. // apply element options
  1020. if (options.id) el.id = options.id
  1021. if (options.className) el.className = options.className
  1022. attrs = options.attributes
  1023. if (attrs) {
  1024. for (attr in attrs) {
  1025. el.setAttribute(attr, attrs[attr])
  1026. }
  1027. }
  1028. return el
  1029. }
  1030. /**
  1031. * Deal with <content> insertion points
  1032. * per the Web Components spec
  1033. */
  1034. CompilerProto.resolveContent = function () {
  1035. var outlets = slice.call(this.el.getElementsByTagName('content')),
  1036. raw = this.rawContent,
  1037. outlet, select, i, j, main
  1038. i = outlets.length
  1039. if (i) {
  1040. // first pass, collect corresponding content
  1041. // for each outlet.
  1042. while (i--) {
  1043. outlet = outlets[i]
  1044. if (raw) {
  1045. select = outlet.getAttribute('select')
  1046. if (select) { // select content
  1047. outlet.content =
  1048. slice.call(raw.querySelectorAll(select))
  1049. } else { // default content
  1050. main = outlet
  1051. }
  1052. } else { // fallback content
  1053. outlet.content =
  1054. slice.call(outlet.childNodes)
  1055. }
  1056. }
  1057. // second pass, actually insert the contents
  1058. for (i = 0, j = outlets.length; i < j; i++) {
  1059. outlet = outlets[i]
  1060. if (outlet === main) continue
  1061. insert(outlet, outlet.content)
  1062. }
  1063. // finally insert the main content
  1064. if (raw && main) {
  1065. insert(main, slice.call(raw.childNodes))
  1066. }
  1067. }
  1068. function insert (outlet, contents) {
  1069. var parent = outlet.parentNode,
  1070. i = 0, j = contents.length
  1071. for (; i < j; i++) {
  1072. parent.insertBefore(contents[i], outlet)
  1073. }
  1074. parent.removeChild(outlet)
  1075. }
  1076. this.rawContent = null
  1077. }
  1078. /**
  1079. * Setup observer.
  1080. * The observer listens for get/set/mutate events on all VM
  1081. * values/objects and trigger corresponding binding updates.
  1082. * It also listens for lifecycle hooks.
  1083. */
  1084. CompilerProto.setupObserver = function () {
  1085. var compiler = this,
  1086. bindings = compiler.bindings,
  1087. options = compiler.options,
  1088. observer = compiler.observer = new Emitter(compiler.vm)
  1089. // a hash to hold event proxies for each root level key
  1090. // so they can be referenced and removed later
  1091. observer.proxies = {}
  1092. // add own listeners which trigger binding updates
  1093. observer
  1094. .on('get', onGet)
  1095. .on('set', onSet)
  1096. .on('mutate', onSet)
  1097. // register hooks
  1098. var i = hooks.length, j, hook, fns
  1099. while (i--) {
  1100. hook = hooks[i]
  1101. fns = options[hook]
  1102. if (Array.isArray(fns)) {
  1103. j = fns.length
  1104. // since hooks were merged with child at head,
  1105. // we loop reversely.
  1106. while (j--) {
  1107. registerHook(hook, fns[j])
  1108. }
  1109. } else if (fns) {
  1110. registerHook(hook, fns)
  1111. }
  1112. }
  1113. // broadcast attached/detached hooks
  1114. observer
  1115. .on('hook:attached', function () {
  1116. broadcast(1)
  1117. })
  1118. .on('hook:detached', function () {
  1119. broadcast(0)
  1120. })
  1121. function onGet (key) {
  1122. check(key)
  1123. DepsParser.catcher.emit('get', bindings[key])
  1124. }
  1125. function onSet (key, val, mutation) {
  1126. observer.emit('change:' + key, val, mutation)
  1127. check(key)
  1128. bindings[key].update(val)
  1129. }
  1130. function registerHook (hook, fn) {
  1131. observer.on('hook:' + hook, function () {
  1132. fn.call(compiler.vm)
  1133. })
  1134. }
  1135. function broadcast (event) {
  1136. var children = compiler.children
  1137. if (children) {
  1138. var child, i = children.length
  1139. while (i--) {
  1140. child = children[i]
  1141. if (child.el.parentNode) {
  1142. event = 'hook:' + (event ? 'attached' : 'detached')
  1143. child.observer.emit(event)
  1144. child.emitter.emit(event)
  1145. }
  1146. }
  1147. }
  1148. }
  1149. function check (key) {
  1150. if (!bindings[key]) {
  1151. compiler.createBinding(key)
  1152. }
  1153. }
  1154. }
  1155. CompilerProto.observeData = function (data) {
  1156. var compiler = this,
  1157. observer = compiler.observer
  1158. // recursively observe nested properties
  1159. Observer.observe(data, '', observer)
  1160. // also create binding for top level $data
  1161. // so it can be used in templates too
  1162. var $dataBinding = compiler.bindings['$data'] = new Binding(compiler, '$data')
  1163. $dataBinding.update(data)
  1164. // allow $data to be swapped
  1165. def(compiler.vm, '$data', {
  1166. get: function () {
  1167. compiler.observer.emit('get', '$data')
  1168. return compiler.data
  1169. },
  1170. set: function (newData) {
  1171. var oldData = compiler.data
  1172. Observer.unobserve(oldData, '', observer)
  1173. compiler.data = newData
  1174. Observer.copyPaths(newData, oldData)
  1175. Observer.observe(newData, '', observer)
  1176. update()
  1177. }
  1178. })
  1179. // emit $data change on all changes
  1180. observer
  1181. .on('set', onSet)
  1182. .on('mutate', onSet)
  1183. function onSet (key) {
  1184. if (key !== '$data') update()
  1185. }
  1186. function update () {
  1187. $dataBinding.update(compiler.data)
  1188. observer.emit('change:$data', compiler.data)
  1189. }
  1190. }
  1191. /**
  1192. * Compile a DOM node (recursive)
  1193. */
  1194. CompilerProto.compile = function (node, root) {
  1195. var nodeType = node.nodeType
  1196. if (nodeType === 1 && node.tagName !== 'SCRIPT') { // a normal node
  1197. this.compileElement(node, root)
  1198. } else if (nodeType === 3 && config.interpolate) {
  1199. this.compileTextNode(node)
  1200. }
  1201. }
  1202. /**
  1203. * Check for a priority directive
  1204. * If it is present and valid, return true to skip the rest
  1205. */
  1206. CompilerProto.checkPriorityDir = function (dirname, node, root) {
  1207. var expression, directive, Ctor
  1208. if (
  1209. dirname === 'component' &&
  1210. root !== true &&
  1211. (Ctor = this.resolveComponent(node, undefined, true))
  1212. ) {
  1213. directive = this.parseDirective(dirname, '', node)
  1214. directive.Ctor = Ctor
  1215. } else {
  1216. expression = utils.attr(node, dirname)
  1217. directive = expression && this.parseDirective(dirname, expression, node)
  1218. }
  1219. if (directive) {
  1220. if (root === true) {
  1221. utils.warn(
  1222. 'Directive v-' + dirname + ' cannot be used on an already instantiated ' +
  1223. 'VM\'s root node. Use it from the parent\'s template instead.'
  1224. )
  1225. return
  1226. }
  1227. this.deferred.push(directive)
  1228. return true
  1229. }
  1230. }
  1231. /**
  1232. * Compile normal directives on a node
  1233. */
  1234. CompilerProto.compileElement = function (node, root) {
  1235. // textarea is pretty annoying
  1236. // because its value creates childNodes which
  1237. // we don't want to compile.
  1238. if (node.tagName === 'TEXTAREA' && node.value) {
  1239. node.value = this.eval(node.value)
  1240. }
  1241. // only compile if this element has attributes
  1242. // or its tagName contains a hyphen (which means it could
  1243. // potentially be a custom element)
  1244. if (node.hasAttributes() || node.tagName.indexOf('-') > -1) {
  1245. // skip anything with v-pre
  1246. if (utils.attr(node, 'pre') !== null) {
  1247. return
  1248. }
  1249. var i, l, j, k
  1250. // check priority directives.
  1251. // if any of them are present, it will take over the node with a childVM
  1252. // so we can skip the rest
  1253. for (i = 0, l = priorityDirectives.length; i < l; i++) {
  1254. if (this.checkPriorityDir(priorityDirectives[i], node, root)) {
  1255. return
  1256. }
  1257. }
  1258. // check transition & animation properties
  1259. node.vue_trans = utils.attr(node, 'transition')
  1260. node.vue_anim = utils.attr(node, 'animation')
  1261. node.vue_effect = this.eval(utils.attr(node, 'effect'))
  1262. var prefix = config.prefix + '-',
  1263. params = this.options.paramAttributes,
  1264. attr, attrname, isDirective, exp, directives, directive, dirname
  1265. // v-with has special priority among the rest
  1266. // it needs to pull in the value from the parent before
  1267. // computed properties are evaluated, because at this stage
  1268. // the computed properties have not set up their dependencies yet.
  1269. if (root) {
  1270. var withExp = utils.attr(node, 'with')
  1271. if (withExp) {
  1272. directives = this.parseDirective('with', withExp, node, true)
  1273. for (j = 0, k = directives.length; j < k; j++) {
  1274. this.bindDirective(directives[j], this.parent)
  1275. }
  1276. }
  1277. }
  1278. var attrs = slice.call(node.attributes)
  1279. for (i = 0, l = attrs.length; i < l; i++) {
  1280. attr = attrs[i]
  1281. attrname = attr.name
  1282. isDirective = false
  1283. if (attrname.indexOf(prefix) === 0) {
  1284. // a directive - split, parse and bind it.
  1285. isDirective = true
  1286. dirname = attrname.slice(prefix.length)
  1287. // build with multiple: true
  1288. directives = this.parseDirective(dirname, attr.value, node, true)
  1289. // loop through clauses (separated by ",")
  1290. // inside each attribute
  1291. for (j = 0, k = directives.length; j < k; j++) {
  1292. this.bindDirective(directives[j])
  1293. }
  1294. } else if (config.interpolate) {
  1295. // non directive attribute, check interpolation tags
  1296. exp = TextParser.parseAttr(attr.value)
  1297. if (exp) {
  1298. directive = this.parseDirective('attr', exp, node)
  1299. directive.arg = attrname
  1300. if (params && params.indexOf(attrname) > -1) {
  1301. // a param attribute... we should use the parent binding
  1302. // to avoid circular updates like size={{size}}
  1303. this.bindDirective(directive, this.parent)
  1304. } else {
  1305. this.bindDirective(directive)
  1306. }
  1307. }
  1308. }
  1309. if (isDirective && dirname !== 'cloak') {
  1310. node.removeAttribute(attrname)
  1311. }
  1312. }
  1313. }
  1314. // recursively compile childNodes
  1315. if (node.hasChildNodes()) {
  1316. slice.call(node.childNodes).forEach(this.compile, this)
  1317. }
  1318. }
  1319. /**
  1320. * Compile a text node
  1321. */
  1322. CompilerProto.compileTextNode = function (node) {
  1323. var tokens = TextParser.parse(node.nodeValue)
  1324. if (!tokens) return
  1325. var el, token, directive
  1326. for (var i = 0, l = tokens.length; i < l; i++) {
  1327. token = tokens[i]
  1328. directive = null
  1329. if (token.key) { // a binding
  1330. if (token.key.charAt(0) === '>') { // a partial
  1331. el = document.createComment('ref')
  1332. directive = this.parseDirective('partial', token.key.slice(1), el)
  1333. } else {
  1334. if (!token.html) { // text binding
  1335. el = document.createTextNode('')
  1336. directive = this.parseDirective('text', token.key, el)
  1337. } else { // html binding
  1338. el = document.createComment(config.prefix + '-html')
  1339. directive = this.parseDirective('html', token.key, el)
  1340. }
  1341. }
  1342. } else { // a plain string
  1343. el = document.createTextNode(token)
  1344. }
  1345. // insert node
  1346. node.parentNode.insertBefore(el, node)
  1347. // bind directive
  1348. this.bindDirective(directive)
  1349. }
  1350. node.parentNode.removeChild(node)
  1351. }
  1352. /**
  1353. * Parse a directive name/value pair into one or more
  1354. * directive instances
  1355. */
  1356. CompilerProto.parseDirective = function (name, value, el, multiple) {
  1357. var compiler = this,
  1358. definition = compiler.getOption('directives', name)
  1359. if (definition) {
  1360. // parse into AST-like objects
  1361. var asts = Directive.parse(value)
  1362. return multiple
  1363. ? asts.map(build)
  1364. : build(asts[0])
  1365. }
  1366. function build (ast) {
  1367. return new Directive(name, ast, definition, compiler, el)
  1368. }
  1369. }
  1370. /**
  1371. * Add a directive instance to the correct binding & viewmodel
  1372. */
  1373. CompilerProto.bindDirective = function (directive, bindingOwner) {
  1374. if (!directive) return
  1375. // keep track of it so we can unbind() later
  1376. this.dirs.push(directive)
  1377. // for empty or literal directives, simply call its bind()
  1378. // and we're done.
  1379. if (directive.isEmpty || directive.isLiteral) {
  1380. if (directive.bind) directive.bind()
  1381. return
  1382. }
  1383. // otherwise, we got more work to do...
  1384. var binding,
  1385. compiler = bindingOwner || this,
  1386. key = directive.key
  1387. if (directive.isExp) {
  1388. // expression bindings are always created on current compiler
  1389. binding = compiler.createBinding(key, directive)
  1390. } else {
  1391. // recursively locate which compiler owns the binding
  1392. while (compiler) {
  1393. if (compiler.hasKey(key)) {
  1394. break
  1395. } else {
  1396. compiler = compiler.parent
  1397. }
  1398. }
  1399. compiler = compiler || this
  1400. binding = compiler.bindings[key] || compiler.createBinding(key)
  1401. }
  1402. binding.dirs.push(directive)
  1403. directive.binding = binding
  1404. var value = binding.val()
  1405. // invoke bind hook if exists
  1406. if (directive.bind) {
  1407. directive.bind(value)
  1408. }
  1409. // set initial value
  1410. directive.$update(value, true)
  1411. }
  1412. /**
  1413. * Create binding and attach getter/setter for a key to the viewmodel object
  1414. */
  1415. CompilerProto.createBinding = function (key, directive) {
  1416. utils.log(' created binding: ' + key)
  1417. var compiler = this,
  1418. methods = compiler.options.methods,
  1419. isExp = directive && directive.isExp,
  1420. isFn = (directive && directive.isFn) || (methods && methods[key]),
  1421. bindings = compiler.bindings,
  1422. computed = compiler.options.computed,
  1423. binding = new Binding(compiler, key, isExp, isFn)
  1424. if (isExp) {
  1425. // expression bindings are anonymous
  1426. compiler.defineExp(key, binding, directive)
  1427. } else if (isFn) {
  1428. bindings[key] = binding
  1429. compiler.defineVmProp(key, binding, methods[key])
  1430. } else {
  1431. bindings[key] = binding
  1432. if (binding.root) {
  1433. // this is a root level binding. we need to define getter/setters for it.
  1434. if (computed && computed[key]) {
  1435. // computed property
  1436. compiler.defineComputed(key, binding, computed[key])
  1437. } else if (key.charAt(0) !== '$') {
  1438. // normal property
  1439. compiler.defineDataProp(key, binding)
  1440. } else {
  1441. // properties that start with $ are meta properties
  1442. // they should be kept on the vm but not in the data object.
  1443. compiler.defineVmProp(key, binding, compiler.data[key])
  1444. delete compiler.data[key]
  1445. }
  1446. } else if (computed && computed[utils.baseKey(key)]) {
  1447. // nested path on computed property
  1448. compiler.defineExp(key, binding)
  1449. } else {
  1450. // ensure path in data so that computed properties that
  1451. // access the path don't throw an error and can collect
  1452. // dependencies
  1453. Observer.ensurePath(compiler.data, key)
  1454. var parentKey = key.slice(0, key.lastIndexOf('.'))
  1455. if (!bindings[parentKey]) {
  1456. // this is a nested value binding, but the binding for its parent
  1457. // has not been created yet. We better create that one too.
  1458. compiler.createBinding(parentKey)
  1459. }
  1460. }
  1461. }
  1462. return binding
  1463. }
  1464. /**
  1465. * Define the getter/setter to proxy a root-level
  1466. * data property on the VM
  1467. */
  1468. CompilerProto.defineDataProp = function (key, binding) {
  1469. var compiler = this,
  1470. data = compiler.data,
  1471. ob = data.__emitter__
  1472. // make sure the key is present in data
  1473. // so it can be observed
  1474. if (!(hasOwn.call(data, key))) {
  1475. data[key] = undefined
  1476. }
  1477. // if the data object is already observed, but the key
  1478. // is not observed, we need to add it to the observed keys.
  1479. if (ob && !(hasOwn.call(ob.values, key))) {
  1480. Observer.convertKey(data, key)
  1481. }
  1482. binding.value = data[key]
  1483. def(compiler.vm, key, {
  1484. get: function () {
  1485. return compiler.data[key]
  1486. },
  1487. set: function (val) {
  1488. compiler.data[key] = val
  1489. }
  1490. })
  1491. }
  1492. /**
  1493. * Define a vm property, e.g. $index, $key, or mixin methods
  1494. * which are bindable but only accessible on the VM,
  1495. * not in the data.
  1496. */
  1497. CompilerProto.defineVmProp = function (key, binding, value) {
  1498. var ob = this.observer
  1499. binding.value = value
  1500. def(this.vm, key, {
  1501. get: function () {
  1502. if (Observer.shouldGet) ob.emit('get', key)
  1503. return binding.value
  1504. },
  1505. set: function (val) {
  1506. ob.emit('set', key, val)
  1507. }
  1508. })
  1509. }
  1510. /**
  1511. * Define an expression binding, which is essentially
  1512. * an anonymous computed property
  1513. */
  1514. CompilerProto.defineExp = function (key, binding, directive) {
  1515. var computedKey = directive && directive.computedKey,
  1516. exp = computedKey ? directive.expression : key,
  1517. getter = this.expCache[exp]
  1518. if (!getter) {
  1519. getter = this.expCache[exp] = ExpParser.parse(computedKey || key, this)
  1520. }
  1521. if (getter) {
  1522. this.markComputed(binding, getter)
  1523. }
  1524. }
  1525. /**
  1526. * Define a computed property on the VM
  1527. */
  1528. CompilerProto.defineComputed = function (key, binding, value) {
  1529. this.markComputed(binding, value)
  1530. def(this.vm, key, {
  1531. get: binding.value.$get,
  1532. set: binding.value.$set
  1533. })
  1534. }
  1535. /**
  1536. * Process a computed property binding
  1537. * so its getter/setter are bound to proper context
  1538. */
  1539. CompilerProto.markComputed = function (binding, value) {
  1540. binding.isComputed = true
  1541. // bind the accessors to the vm
  1542. if (binding.isFn) {
  1543. binding.value = value
  1544. } else {
  1545. if (typeof value === 'function') {
  1546. value = { $get: value }
  1547. }
  1548. binding.value = {
  1549. $get: utils.bind(value.$get, this.vm),
  1550. $set: value.$set
  1551. ? utils.bind(value.$set, this.vm)
  1552. : undefined
  1553. }
  1554. }
  1555. // keep track for dep parsing later
  1556. this.computed.push(binding)
  1557. }
  1558. /**
  1559. * Retrive an option from the compiler
  1560. */
  1561. CompilerProto.getOption = function (type, id, silent) {
  1562. var opts = this.options,
  1563. parent = this.parent,
  1564. globalAssets = config.globalAssets,
  1565. res = (opts[type] && opts[type][id]) || (
  1566. parent
  1567. ? parent.getOption(type, id, silent)
  1568. : globalAssets[type] && globalAssets[type][id]
  1569. )
  1570. if (!res && !silent && typeof id === 'string') {
  1571. utils.warn('Unknown ' + type.slice(0, -1) + ': ' + id)
  1572. }
  1573. return res
  1574. }
  1575. /**
  1576. * Emit lifecycle events to trigger hooks
  1577. */
  1578. CompilerProto.execHook = function (event) {
  1579. event = 'hook:' + event
  1580. this.observer.emit(event)
  1581. this.emitter.emit(event)
  1582. }
  1583. /**
  1584. * Check if a compiler's data contains a keypath
  1585. */
  1586. CompilerProto.hasKey = function (key) {
  1587. var baseKey = utils.baseKey(key)
  1588. return hasOwn.call(this.data, baseKey) ||
  1589. hasOwn.call(this.vm, baseKey)
  1590. }
  1591. /**
  1592. * Do a one-time eval of a string that potentially
  1593. * includes bindings. It accepts additional raw data
  1594. * because we need to dynamically resolve v-component
  1595. * before a childVM is even compiled...
  1596. */
  1597. CompilerProto.eval = function (exp, data) {
  1598. var parsed = TextParser.parseAttr(exp)
  1599. return parsed
  1600. ? ExpParser.eval(parsed, this, data)
  1601. : exp
  1602. }
  1603. /**
  1604. * Resolve a Component constructor for an element
  1605. * with the data to be used
  1606. */
  1607. CompilerProto.resolveComponent = function (node, data, test) {
  1608. // late require to avoid circular deps
  1609. ViewModel = ViewModel || require('./viewmodel')
  1610. var exp = utils.attr(node, 'component'),
  1611. tagName = node.tagName,
  1612. id = this.eval(exp, data),
  1613. tagId = (tagName.indexOf('-') > 0 && tagName.toLowerCase()),
  1614. Ctor = this.getOption('components', id || tagId, true)
  1615. if (id && !Ctor) {
  1616. utils.warn('Unknown component: ' + id)
  1617. }
  1618. return test
  1619. ? exp === ''
  1620. ? ViewModel
  1621. : Ctor
  1622. : Ctor || ViewModel
  1623. }
  1624. /**
  1625. * Unbind and remove element
  1626. */
  1627. CompilerProto.destroy = function (noRemove) {
  1628. // avoid being called more than once
  1629. // this is irreversible!
  1630. if (this.destroyed) return
  1631. var compiler = this,
  1632. i, j, key, dir, dirs, binding,
  1633. vm = compiler.vm,
  1634. el = compiler.el,
  1635. directives = compiler.dirs,
  1636. computed = compiler.computed,
  1637. bindings = compiler.bindings,
  1638. children = compiler.children,
  1639. parent = compiler.parent
  1640. compiler.execHook('beforeDestroy')
  1641. // unobserve data
  1642. Observer.unobserve(compiler.data, '', compiler.observer)
  1643. // destroy all children
  1644. // do not remove their elements since the parent
  1645. // may have transitions and the children may not
  1646. i = children.length
  1647. while (i--) {
  1648. children[i].destroy(true)
  1649. }
  1650. // unbind all direcitves
  1651. i = directives.length
  1652. while (i--) {
  1653. dir = directives[i]
  1654. // if this directive is an instance of an external binding
  1655. // e.g. a directive that refers to a variable on the parent VM
  1656. // we need to remove it from that binding's directives
  1657. // * empty and literal bindings do not have binding.
  1658. if (dir.binding && dir.binding.compiler !== compiler) {
  1659. dirs = dir.binding.dirs
  1660. if (dirs) {
  1661. j = dirs.indexOf(dir)
  1662. if (j > -1) dirs.splice(j, 1)
  1663. }
  1664. }
  1665. dir.$unbind()
  1666. }
  1667. // unbind all computed, anonymous bindings
  1668. i = computed.length
  1669. while (i--) {
  1670. computed[i].unbind()
  1671. }
  1672. // unbind all keypath bindings
  1673. for (key in bindings) {
  1674. binding = bindings[key]
  1675. if (binding) {
  1676. binding.unbind()
  1677. }
  1678. }
  1679. // remove self from parent
  1680. if (parent) {
  1681. j = parent.children.indexOf(compiler)
  1682. if (j > -1) parent.children.splice(j, 1)
  1683. }
  1684. // finally remove dom element
  1685. if (!noRemove) {
  1686. if (el === document.body) {
  1687. el.innerHTML = ''
  1688. } else {
  1689. vm.$remove()
  1690. }
  1691. }
  1692. el.vue_vm = null
  1693. compiler.destroyed = true
  1694. // emit destroy hook
  1695. compiler.execHook('afterDestroy')
  1696. // finally, unregister all listeners
  1697. compiler.observer.off()
  1698. compiler.emitter.off()
  1699. }
  1700. // Helpers --------------------------------------------------------------------
  1701. /**
  1702. * shorthand for getting root compiler
  1703. */
  1704. function getRoot (compiler) {
  1705. while (compiler.parent) {
  1706. compiler = compiler.parent
  1707. }
  1708. return compiler
  1709. }
  1710. module.exports = Compiler
  1711. });
  1712. require.register("vue/src/viewmodel.js", function(exports, require, module){
  1713. var Compiler = require('./compiler'),
  1714. utils = require('./utils'),
  1715. transition = require('./transition'),
  1716. Batcher = require('./batcher'),
  1717. slice = [].slice,
  1718. def = utils.defProtected,
  1719. nextTick = utils.nextTick,
  1720. // batch $watch callbacks
  1721. watcherBatcher = new Batcher(),
  1722. watcherId = 1
  1723. /**
  1724. * ViewModel exposed to the user that holds data,
  1725. * computed properties, event handlers
  1726. * and a few reserved methods
  1727. */
  1728. function ViewModel (options) {
  1729. // compile if options passed, if false return. options are passed directly to compiler
  1730. if (options === false) return
  1731. new Compiler(this, options)
  1732. }
  1733. // All VM prototype methods are inenumerable
  1734. // so it can be stringified/looped through as raw data
  1735. var VMProto = ViewModel.prototype
  1736. /**
  1737. * init allows config compilation after instantiation:
  1738. * var a = new Vue(false)
  1739. * a.init(config)
  1740. */
  1741. def(VMProto, '$init', function (options) {
  1742. new Compiler(this, options)
  1743. })
  1744. /**
  1745. * Convenience function to get a value from
  1746. * a keypath
  1747. */
  1748. def(VMProto, '$get', function (key) {
  1749. var val = utils.get(this, key)
  1750. return val === undefined && this.$parent
  1751. ? this.$parent.$get(key)
  1752. : val
  1753. })
  1754. /**
  1755. * Convenience function to set an actual nested value
  1756. * from a flat key string. Used in directives.
  1757. */
  1758. def(VMProto, '$set', function (key, value) {
  1759. utils.set(this, key, value)
  1760. })
  1761. /**
  1762. * watch a key on the viewmodel for changes
  1763. * fire callback with new value
  1764. */
  1765. def(VMProto, '$watch', function (key, callback) {
  1766. // save a unique id for each watcher
  1767. var id = watcherId++,
  1768. self = this
  1769. function on () {
  1770. var args = slice.call(arguments)
  1771. watcherBatcher.push({
  1772. id: id,
  1773. override: true,
  1774. execute: function () {
  1775. callback.apply(self, args)
  1776. }
  1777. })
  1778. }
  1779. callback._fn = on
  1780. self.$compiler.observer.on('change:' + key, on)
  1781. })
  1782. /**
  1783. * unwatch a key
  1784. */
  1785. def(VMProto, '$unwatch', function (key, callback) {
  1786. // workaround here
  1787. // since the emitter module checks callback existence
  1788. // by checking the length of arguments
  1789. var args = ['change:' + key],
  1790. ob = this.$compiler.observer
  1791. if (callback) args.push(callback._fn)
  1792. ob.off.apply(ob, args)
  1793. })
  1794. /**
  1795. * unbind everything, remove everything
  1796. */
  1797. def(VMProto, '$destroy', function (noRemove) {
  1798. this.$compiler.destroy(noRemove)
  1799. })
  1800. /**
  1801. * broadcast an event to all child VMs recursively.
  1802. */
  1803. def(VMProto, '$broadcast', function () {
  1804. var children = this.$compiler.children,
  1805. i = children.length,
  1806. child
  1807. while (i--) {
  1808. child = children[i]
  1809. child.emitter.applyEmit.apply(child.emitter, arguments)
  1810. child.vm.$broadcast.apply(child.vm, arguments)
  1811. }
  1812. })
  1813. /**
  1814. * emit an event that propagates all the way up to parent VMs.
  1815. */
  1816. def(VMProto, '$dispatch', function () {
  1817. var compiler = this.$compiler,
  1818. emitter = compiler.emitter,
  1819. parent = compiler.parent
  1820. emitter.applyEmit.apply(emitter, arguments)
  1821. if (parent) {
  1822. parent.vm.$dispatch.apply(parent.vm, arguments)
  1823. }
  1824. })
  1825. /**
  1826. * delegate on/off/once to the compiler's emitter
  1827. */
  1828. ;['emit', 'on', 'off', 'once'].forEach(function (method) {
  1829. // internal emit has fixed number of arguments.
  1830. // exposed emit uses the external version
  1831. // with fn.apply.
  1832. var realMethod = method === 'emit'
  1833. ? 'applyEmit'
  1834. : method
  1835. def(VMProto, '$' + method, function () {
  1836. var emitter = this.$compiler.emitter
  1837. emitter[realMethod].apply(emitter, arguments)
  1838. })
  1839. })
  1840. // DOM convenience methods
  1841. def(VMProto, '$appendTo', function (target, cb) {
  1842. target = query(target)
  1843. var el = this.$el
  1844. transition(el, 1, function () {
  1845. target.appendChild(el)
  1846. if (cb) nextTick(cb)
  1847. }, this.$compiler)
  1848. })
  1849. def(VMProto, '$remove', function (cb) {
  1850. var el = this.$el
  1851. transition(el, -1, function () {
  1852. if (el.parentNode) {
  1853. el.parentNode.removeChild(el)
  1854. }
  1855. if (cb) nextTick(cb)
  1856. }, this.$compiler)
  1857. })
  1858. def(VMProto, '$before', function (target, cb) {
  1859. target = query(target)
  1860. var el = this.$el
  1861. transition(el, 1, function () {
  1862. target.parentNode.insertBefore(el, target)
  1863. if (cb) nextTick(cb)
  1864. }, this.$compiler)
  1865. })
  1866. def(VMProto, '$after', function (target, cb) {
  1867. target = query(target)
  1868. var el = this.$el
  1869. transition(el, 1, function () {
  1870. if (target.nextSibling) {
  1871. target.parentNode.insertBefore(el, target.nextSibling)
  1872. } else {
  1873. target.parentNode.appendChild(el)
  1874. }
  1875. if (cb) nextTick(cb)
  1876. }, this.$compiler)
  1877. })
  1878. function query (el) {
  1879. return typeof el === 'string'
  1880. ? document.querySelector(el)
  1881. : el
  1882. }
  1883. module.exports = ViewModel
  1884. });
  1885. require.register("vue/src/binding.js", function(exports, require, module){
  1886. var Batcher = require('./batcher'),
  1887. bindingBatcher = new Batcher(),
  1888. bindingId = 1
  1889. /**
  1890. * Binding class.
  1891. *
  1892. * each property on the viewmodel has one corresponding Binding object
  1893. * which has multiple directive instances on the DOM
  1894. * and multiple computed property dependents
  1895. */
  1896. function Binding (compiler, key, isExp, isFn) {
  1897. this.id = bindingId++
  1898. this.value = undefined
  1899. this.isExp = !!isExp
  1900. this.isFn = isFn
  1901. this.root = !this.isExp && key.indexOf('.') === -1
  1902. this.compiler = compiler
  1903. this.key = key
  1904. this.dirs = []
  1905. this.subs = []
  1906. this.deps = []
  1907. this.unbound = false
  1908. }
  1909. var BindingProto = Binding.prototype
  1910. /**
  1911. * Update value and queue instance updates.
  1912. */
  1913. BindingProto.update = function (value) {
  1914. if (!this.isComputed || this.isFn) {
  1915. this.value = value
  1916. }
  1917. if (this.dirs.length || this.subs.length) {
  1918. var self = this
  1919. bindingBatcher.push({
  1920. id: this.id,
  1921. execute: function () {
  1922. if (!self.unbound) {
  1923. self._update()
  1924. }
  1925. }
  1926. })
  1927. }
  1928. }
  1929. /**
  1930. * Actually update the directives.
  1931. */
  1932. BindingProto._update = function () {
  1933. var i = this.dirs.length,
  1934. value = this.val()
  1935. while (i--) {
  1936. this.dirs[i].$update(value)
  1937. }
  1938. this.pub()
  1939. }
  1940. /**
  1941. * Return the valuated value regardless
  1942. * of whether it is computed or not
  1943. */
  1944. BindingProto.val = function () {
  1945. return this.isComputed && !this.isFn
  1946. ? this.value.$get()
  1947. : this.value
  1948. }
  1949. /**
  1950. * Notify computed properties that depend on this binding
  1951. * to update themselves
  1952. */
  1953. BindingProto.pub = function () {
  1954. var i = this.subs.length
  1955. while (i--) {
  1956. this.subs[i].update()
  1957. }
  1958. }
  1959. /**
  1960. * Unbind the binding, remove itself from all of its dependencies
  1961. */
  1962. BindingProto.unbind = function () {
  1963. // Indicate this has been unbound.
  1964. // It's possible this binding will be in
  1965. // the batcher's flush queue when its owner
  1966. // compiler has already been destroyed.
  1967. this.unbound = true
  1968. var i = this.dirs.length
  1969. while (i--) {
  1970. this.dirs[i].$unbind()
  1971. }
  1972. i = this.deps.length
  1973. var subs
  1974. while (i--) {
  1975. subs = this.deps[i].subs
  1976. var j = subs.indexOf(this)
  1977. if (j > -1) subs.splice(j, 1)
  1978. }
  1979. }
  1980. module.exports = Binding
  1981. });
  1982. require.register("vue/src/observer.js", function(exports, require, module){
  1983. /* jshint proto:true */
  1984. var Emitter = require('./emitter'),
  1985. utils = require('./utils'),
  1986. // cache methods
  1987. def = utils.defProtected,
  1988. isObject = utils.isObject,
  1989. isArray = Array.isArray,
  1990. hasOwn = ({}).hasOwnProperty,
  1991. oDef = Object.defineProperty,
  1992. slice = [].slice,
  1993. // fix for IE + __proto__ problem
  1994. // define methods as inenumerable if __proto__ is present,
  1995. // otherwise enumerable so we can loop through and manually
  1996. // attach to array instances
  1997. hasProto = ({}).__proto__
  1998. // Array Mutation Handlers & Augmentations ------------------------------------
  1999. // The proxy prototype to replace the __proto__ of
  2000. // an observed array
  2001. var ArrayProxy = Object.create(Array.prototype)
  2002. // intercept mutation methods
  2003. ;[
  2004. 'push',
  2005. 'pop',
  2006. 'shift',
  2007. 'unshift',
  2008. 'splice',
  2009. 'sort',
  2010. 'reverse'
  2011. ].forEach(watchMutation)
  2012. // Augment the ArrayProxy with convenience methods
  2013. def(ArrayProxy, '$set', function (index, data) {
  2014. return this.splice(index, 1, data)[0]
  2015. }, !hasProto)
  2016. def(ArrayProxy, '$remove', function (index) {
  2017. if (typeof index !== 'number') {
  2018. index = this.indexOf(index)
  2019. }
  2020. if (index > -1) {
  2021. return this.splice(index, 1)[0]
  2022. }
  2023. }, !hasProto)
  2024. /**
  2025. * Intercep a mutation event so we can emit the mutation info.
  2026. * we also analyze what elements are added/removed and link/unlink
  2027. * them with the parent Array.
  2028. */
  2029. function watchMutation (method) {
  2030. def(ArrayProxy, method, function () {
  2031. var args = slice.call(arguments),
  2032. result = Array.prototype[method].apply(this, args),
  2033. inserted, removed
  2034. // determine new / removed elements
  2035. if (method === 'push' || method === 'unshift') {
  2036. inserted = args
  2037. } else if (method === 'pop' || method === 'shift') {
  2038. removed = [result]
  2039. } else if (method === 'splice') {
  2040. inserted = args.slice(2)
  2041. removed = result
  2042. }
  2043. // link & unlink
  2044. linkArrayElements(this, inserted)
  2045. unlinkArrayElements(this, removed)
  2046. // emit the mutation event
  2047. this.__emitter__.emit('mutate', '', this, {
  2048. method : method,
  2049. args : args,
  2050. result : result,
  2051. inserted : inserted,
  2052. removed : removed
  2053. })
  2054. return result
  2055. }, !hasProto)
  2056. }
  2057. /**
  2058. * Link new elements to an Array, so when they change
  2059. * and emit events, the owner Array can be notified.
  2060. */
  2061. function linkArrayElements (arr, items) {
  2062. if (items) {
  2063. var i = items.length, item, owners
  2064. while (i--) {
  2065. item = items[i]
  2066. if (isWatchable(item)) {
  2067. // if object is not converted for observing
  2068. // convert it...
  2069. if (!item.__emitter__) {
  2070. convert(item)
  2071. watch(item)
  2072. }
  2073. owners = item.__emitter__.owners
  2074. if (owners.indexOf(arr) < 0) {
  2075. owners.push(arr)
  2076. }
  2077. }
  2078. }
  2079. }
  2080. }
  2081. /**
  2082. * Unlink removed elements from the ex-owner Array.
  2083. */
  2084. function unlinkArrayElements (arr, items) {
  2085. if (items) {
  2086. var i = items.length, item
  2087. while (i--) {
  2088. item = items[i]
  2089. if (item && item.__emitter__) {
  2090. var owners = item.__emitter__.owners
  2091. if (owners) owners.splice(owners.indexOf(arr))
  2092. }
  2093. }
  2094. }
  2095. }
  2096. // Object add/delete key augmentation -----------------------------------------
  2097. var ObjProxy = Object.create(Object.prototype)
  2098. def(ObjProxy, '$add', function (key, val) {
  2099. if (hasOwn.call(this, key)) return
  2100. this[key] = val
  2101. convertKey(this, key, true)
  2102. }, !hasProto)
  2103. def(ObjProxy, '$delete', function (key) {
  2104. if (!(hasOwn.call(this, key))) return
  2105. // trigger set events
  2106. this[key] = undefined
  2107. delete this[key]
  2108. this.__emitter__.emit('delete', key)
  2109. }, !hasProto)
  2110. // Watch Helpers --------------------------------------------------------------
  2111. /**
  2112. * Check if a value is watchable
  2113. */
  2114. function isWatchable (obj) {
  2115. return typeof obj === 'object' && obj && !obj.$compiler
  2116. }
  2117. /**
  2118. * Convert an Object/Array to give it a change emitter.
  2119. */
  2120. function convert (obj) {
  2121. if (obj.__emitter__) return true
  2122. var emitter = new Emitter()
  2123. def(obj, '__emitter__', emitter)
  2124. emitter
  2125. .on('set', function (key, val, propagate) {
  2126. if (propagate) propagateChange(obj)
  2127. })
  2128. .on('mutate', function () {
  2129. propagateChange(obj)
  2130. })
  2131. emitter.values = utils.hash()
  2132. emitter.owners = []
  2133. return false
  2134. }
  2135. /**
  2136. * Propagate an array element's change to its owner arrays
  2137. */
  2138. function propagateChange (obj) {
  2139. var owners = obj.__emitter__.owners,
  2140. i = owners.length
  2141. while (i--) {
  2142. owners[i].__emitter__.emit('set', '', '', true)
  2143. }
  2144. }
  2145. /**
  2146. * Watch target based on its type
  2147. */
  2148. function watch (obj) {
  2149. if (isArray(obj)) {
  2150. watchArray(obj)
  2151. } else {
  2152. watchObject(obj)
  2153. }
  2154. }
  2155. /**
  2156. * Augment target objects with modified
  2157. * methods
  2158. */
  2159. function augment (target, src) {
  2160. if (hasProto) {
  2161. target.__proto__ = src
  2162. } else {
  2163. for (var key in src) {
  2164. def(target, key, src[key])
  2165. }
  2166. }
  2167. }
  2168. /**
  2169. * Watch an Object, recursive.
  2170. */
  2171. function watchObject (obj) {
  2172. augment(obj, ObjProxy)
  2173. for (var key in obj) {
  2174. convertKey(obj, key)
  2175. }
  2176. }
  2177. /**
  2178. * Watch an Array, overload mutation methods
  2179. * and add augmentations by intercepting the prototype chain
  2180. */
  2181. function watchArray (arr) {
  2182. augment(arr, ArrayProxy)
  2183. linkArrayElements(arr, arr)
  2184. }
  2185. /**
  2186. * Define accessors for a property on an Object
  2187. * so it emits get/set events.
  2188. * Then watch the value itself.
  2189. */
  2190. function convertKey (obj, key, propagate) {
  2191. var keyPrefix = key.charAt(0)
  2192. if (keyPrefix === '$' || keyPrefix === '_') {
  2193. return
  2194. }
  2195. // emit set on bind
  2196. // this means when an object is observed it will emit
  2197. // a first batch of set events.
  2198. var emitter = obj.__emitter__,
  2199. values = emitter.values
  2200. init(obj[key], propagate)
  2201. oDef(obj, key, {
  2202. enumerable: true,
  2203. configurable: true,
  2204. get: function () {
  2205. var value = values[key]
  2206. // only emit get on tip values
  2207. if (pub.shouldGet) {
  2208. emitter.emit('get', key)
  2209. }
  2210. return value
  2211. },
  2212. set: function (newVal) {
  2213. var oldVal = values[key]
  2214. unobserve(oldVal, key, emitter)
  2215. copyPaths(newVal, oldVal)
  2216. // an immediate property should notify its parent
  2217. // to emit set for itself too
  2218. init(newVal, true)
  2219. }
  2220. })
  2221. function init (val, propagate) {
  2222. values[key] = val
  2223. emitter.emit('set', key, val, propagate)
  2224. if (isArray(val)) {
  2225. emitter.emit('set', key + '.length', val.length, propagate)
  2226. }
  2227. observe(val, key, emitter)
  2228. }
  2229. }
  2230. /**
  2231. * When a value that is already converted is
  2232. * observed again by another observer, we can skip
  2233. * the watch conversion and simply emit set event for
  2234. * all of its properties.
  2235. */
  2236. function emitSet (obj) {
  2237. var emitter = obj && obj.__emitter__
  2238. if (!emitter) return
  2239. if (isArray(obj)) {
  2240. emitter.emit('set', 'length', obj.length)
  2241. } else {
  2242. var key, val
  2243. for (key in obj) {
  2244. val = obj[key]
  2245. emitter.emit('set', key, val)
  2246. emitSet(val)
  2247. }
  2248. }
  2249. }
  2250. /**
  2251. * Make sure all the paths in an old object exists
  2252. * in a new object.
  2253. * So when an object changes, all missing keys will
  2254. * emit a set event with undefined value.
  2255. */
  2256. function copyPaths (newObj, oldObj) {
  2257. if (!isObject(newObj) || !isObject(oldObj)) {
  2258. return
  2259. }
  2260. var path, oldVal, newVal
  2261. for (path in oldObj) {
  2262. if (!(hasOwn.call(newObj, path))) {
  2263. oldVal = oldObj[path]
  2264. if (isArray(oldVal)) {
  2265. newObj[path] = []
  2266. } else if (isObject(oldVal)) {
  2267. newVal = newObj[path] = {}
  2268. copyPaths(newVal, oldVal)
  2269. } else {
  2270. newObj[path] = undefined
  2271. }
  2272. }
  2273. }
  2274. }
  2275. /**
  2276. * walk along a path and make sure it can be accessed
  2277. * and enumerated in that object
  2278. */
  2279. function ensurePath (obj, key) {
  2280. var path = key.split('.'), sec
  2281. for (var i = 0, d = path.length - 1; i < d; i++) {
  2282. sec = path[i]
  2283. if (!obj[sec]) {
  2284. obj[sec] = {}
  2285. if (obj.__emitter__) convertKey(obj, sec)
  2286. }
  2287. obj = obj[sec]
  2288. }
  2289. if (isObject(obj)) {
  2290. sec = path[i]
  2291. if (!(hasOwn.call(obj, sec))) {
  2292. obj[sec] = undefined
  2293. if (obj.__emitter__) convertKey(obj, sec)
  2294. }
  2295. }
  2296. }
  2297. // Main API Methods -----------------------------------------------------------
  2298. /**
  2299. * Observe an object with a given path,
  2300. * and proxy get/set/mutate events to the provided observer.
  2301. */
  2302. function observe (obj, rawPath, observer) {
  2303. if (!isWatchable(obj)) return
  2304. var path = rawPath ? rawPath + '.' : '',
  2305. alreadyConverted = convert(obj),
  2306. emitter = obj.__emitter__
  2307. // setup proxy listeners on the parent observer.
  2308. // we need to keep reference to them so that they
  2309. // can be removed when the object is un-observed.
  2310. observer.proxies = observer.proxies || {}
  2311. var proxies = observer.proxies[path] = {
  2312. get: function (key) {
  2313. observer.emit('get', path + key)
  2314. },
  2315. set: function (key, val, propagate) {
  2316. if (key) observer.emit('set', path + key, val)
  2317. // also notify observer that the object itself changed
  2318. // but only do so when it's a immediate property. this
  2319. // avoids duplicate event firing.
  2320. if (rawPath && propagate) {
  2321. observer.emit('set', rawPath, obj, true)
  2322. }
  2323. },
  2324. mutate: function (key, val, mutation) {
  2325. // if the Array is a root value
  2326. // the key will be null
  2327. var fixedPath = key ? path + key : rawPath
  2328. observer.emit('mutate', fixedPath, val, mutation)
  2329. // also emit set for Array's length when it mutates
  2330. var m = mutation.method
  2331. if (m !== 'sort' && m !== 'reverse') {
  2332. observer.emit('set', fixedPath + '.length', val.length)
  2333. }
  2334. }
  2335. }
  2336. // attach the listeners to the child observer.
  2337. // now all the events will propagate upwards.
  2338. emitter
  2339. .on('get', proxies.get)
  2340. .on('set', proxies.set)
  2341. .on('mutate', proxies.mutate)
  2342. if (alreadyConverted) {
  2343. // for objects that have already been converted,
  2344. // emit set events for everything inside
  2345. emitSet(obj)
  2346. } else {
  2347. watch(obj)
  2348. }
  2349. }
  2350. /**
  2351. * Cancel observation, turn off the listeners.
  2352. */
  2353. function unobserve (obj, path, observer) {
  2354. if (!obj || !obj.__emitter__) return
  2355. path = path ? path + '.' : ''
  2356. var proxies = observer.proxies[path]
  2357. if (!proxies) return
  2358. // turn off listeners
  2359. obj.__emitter__
  2360. .off('get', proxies.get)
  2361. .off('set', proxies.set)
  2362. .off('mutate', proxies.mutate)
  2363. // remove reference
  2364. observer.proxies[path] = null
  2365. }
  2366. // Expose API -----------------------------------------------------------------
  2367. var pub = module.exports = {
  2368. // whether to emit get events
  2369. // only enabled during dependency parsing
  2370. shouldGet : false,
  2371. observe : observe,
  2372. unobserve : unobserve,
  2373. ensurePath : ensurePath,
  2374. copyPaths : copyPaths,
  2375. watch : watch,
  2376. convert : convert,
  2377. convertKey : convertKey
  2378. }
  2379. });
  2380. require.register("vue/src/directive.js", function(exports, require, module){
  2381. var dirId = 1,
  2382. ARG_RE = /^[\w\$-]+$/,
  2383. FILTER_TOKEN_RE = /[^\s'"]+|'[^']+'|"[^"]+"/g,
  2384. NESTING_RE = /^\$(parent|root)\./,
  2385. SINGLE_VAR_RE = /^[\w\.$]+$/,
  2386. QUOTE_RE = /"/g,
  2387. TextParser = require('./text-parser')
  2388. /**
  2389. * Directive class
  2390. * represents a single directive instance in the DOM
  2391. */
  2392. function Directive (name, ast, definition, compiler, el) {
  2393. this.id = dirId++
  2394. this.name = name
  2395. this.compiler = compiler
  2396. this.vm = compiler.vm
  2397. this.el = el
  2398. this.computeFilters = false
  2399. this.key = ast.key
  2400. this.arg = ast.arg
  2401. this.expression = ast.expression
  2402. var isEmpty = this.expression === ''
  2403. // mix in properties from the directive definition
  2404. if (typeof definition === 'function') {
  2405. this[isEmpty ? 'bind' : 'update'] = definition
  2406. } else {
  2407. for (var prop in definition) {
  2408. this[prop] = definition[prop]
  2409. }
  2410. }
  2411. // empty expression, we're done.
  2412. if (isEmpty || this.isEmpty) {
  2413. this.isEmpty = true
  2414. return
  2415. }
  2416. if (TextParser.Regex.test(this.key)) {
  2417. this.key = compiler.eval(this.key)
  2418. if (this.isLiteral) {
  2419. this.expression = this.key
  2420. }
  2421. }
  2422. var filters = ast.filters,
  2423. filter, fn, i, l, computed
  2424. if (filters) {
  2425. this.filters = []
  2426. for (i = 0, l = filters.length; i < l; i++) {
  2427. filter = filters[i]
  2428. fn = this.compiler.getOption('filters', filter.name)
  2429. if (fn) {
  2430. filter.apply = fn
  2431. this.filters.push(filter)
  2432. if (fn.computed) {
  2433. computed = true
  2434. }
  2435. }
  2436. }
  2437. }
  2438. if (!this.filters || !this.filters.length) {
  2439. this.filters = null
  2440. }
  2441. if (computed) {
  2442. this.computedKey = Directive.inlineFilters(this.key, this.filters)
  2443. this.filters = null
  2444. }
  2445. this.isExp =
  2446. computed ||
  2447. !SINGLE_VAR_RE.test(this.key) ||
  2448. NESTING_RE.test(this.key)
  2449. }
  2450. var DirProto = Directive.prototype
  2451. /**
  2452. * called when a new value is set
  2453. * for computed properties, this will only be called once
  2454. * during initialization.
  2455. */
  2456. DirProto.$update = function (value, init) {
  2457. if (this.$lock) return
  2458. if (init || value !== this.value || (value && typeof value === 'object')) {
  2459. this.value = value
  2460. if (this.update) {
  2461. this.update(
  2462. this.filters && !this.computeFilters
  2463. ? this.$applyFilters(value)
  2464. : value,
  2465. init
  2466. )
  2467. }
  2468. }
  2469. }
  2470. /**
  2471. * pipe the value through filters
  2472. */
  2473. DirProto.$applyFilters = function (value) {
  2474. var filtered = value, filter
  2475. for (var i = 0, l = this.filters.length; i < l; i++) {
  2476. filter = this.filters[i]
  2477. filtered = filter.apply.apply(this.vm, [filtered].concat(filter.args))
  2478. }
  2479. return filtered
  2480. }
  2481. /**
  2482. * Unbind diretive
  2483. */
  2484. DirProto.$unbind = function () {
  2485. // this can be called before the el is even assigned...
  2486. if (!this.el || !this.vm) return
  2487. if (this.unbind) this.unbind()
  2488. this.vm = this.el = this.binding = this.compiler = null
  2489. }
  2490. // Exposed static methods -----------------------------------------------------
  2491. /**
  2492. * Parse a directive string into an Array of
  2493. * AST-like objects representing directives
  2494. */
  2495. Directive.parse = function (str) {
  2496. var inSingle = false,
  2497. inDouble = false,
  2498. curly = 0,
  2499. square = 0,
  2500. paren = 0,
  2501. begin = 0,
  2502. argIndex = 0,
  2503. dirs = [],
  2504. dir = {},
  2505. lastFilterIndex = 0,
  2506. arg
  2507. for (var c, i = 0, l = str.length; i < l; i++) {
  2508. c = str.charAt(i)
  2509. if (inSingle) {
  2510. // check single quote
  2511. if (c === "'") inSingle = !inSingle
  2512. } else if (inDouble) {
  2513. // check double quote
  2514. if (c === '"') inDouble = !inDouble
  2515. } else if (c === ',' && !paren && !curly && !square) {
  2516. // reached the end of a directive
  2517. pushDir()
  2518. // reset & skip the comma
  2519. dir = {}
  2520. begin = argIndex = lastFilterIndex = i + 1
  2521. } else if (c === ':' && !dir.key && !dir.arg) {
  2522. // argument
  2523. arg = str.slice(begin, i).trim()
  2524. if (ARG_RE.test(arg)) {
  2525. argIndex = i + 1
  2526. dir.arg = arg
  2527. }
  2528. } else if (c === '|' && str.charAt(i + 1) !== '|' && str.charAt(i - 1) !== '|') {
  2529. if (dir.key === undefined) {
  2530. // first filter, end of key
  2531. lastFilterIndex = i + 1
  2532. dir.key = str.slice(argIndex, i).trim()
  2533. } else {
  2534. // already has filter
  2535. pushFilter()
  2536. }
  2537. } else if (c === '"') {
  2538. inDouble = true
  2539. } else if (c === "'") {
  2540. inSingle = true
  2541. } else if (c === '(') {
  2542. paren++
  2543. } else if (c === ')') {
  2544. paren--
  2545. } else if (c === '[') {
  2546. square++
  2547. } else if (c === ']') {
  2548. square--
  2549. } else if (c === '{') {
  2550. curly++
  2551. } else if (c === '}') {
  2552. curly--
  2553. }
  2554. }
  2555. if (i === 0 || begin !== i) {
  2556. pushDir()
  2557. }
  2558. function pushDir () {
  2559. dir.expression = str.slice(begin, i).trim()
  2560. if (dir.key === undefined) {
  2561. dir.key = str.slice(argIndex, i).trim()
  2562. } else if (lastFilterIndex !== begin) {
  2563. pushFilter()
  2564. }
  2565. if (i === 0 || dir.key) {
  2566. dirs.push(dir)
  2567. }
  2568. }
  2569. function pushFilter () {
  2570. var exp = str.slice(lastFilterIndex, i).trim(),
  2571. filter
  2572. if (exp) {
  2573. filter = {}
  2574. var tokens = exp.match(FILTER_TOKEN_RE)
  2575. filter.name = tokens[0]
  2576. filter.args = tokens.length > 1 ? tokens.slice(1) : null
  2577. }
  2578. if (filter) {
  2579. (dir.filters = dir.filters || []).push(filter)
  2580. }
  2581. lastFilterIndex = i + 1
  2582. }
  2583. return dirs
  2584. }
  2585. /**
  2586. * Inline computed filters so they become part
  2587. * of the expression
  2588. */
  2589. Directive.inlineFilters = function (key, filters) {
  2590. var args, filter
  2591. for (var i = 0, l = filters.length; i < l; i++) {
  2592. filter = filters[i]
  2593. args = filter.args
  2594. ? ',"' + filter.args.map(escapeQuote).join('","') + '"'
  2595. : ''
  2596. key = 'this.$compiler.getOption("filters", "' +
  2597. filter.name +
  2598. '").call(this,' +
  2599. key + args +
  2600. ')'
  2601. }
  2602. return key
  2603. }
  2604. /**
  2605. * Convert double quotes to single quotes
  2606. * so they don't mess up the generated function body
  2607. */
  2608. function escapeQuote (v) {
  2609. return v.indexOf('"') > -1
  2610. ? v.replace(QUOTE_RE, '\'')
  2611. : v
  2612. }
  2613. module.exports = Directive
  2614. });
  2615. require.register("vue/src/exp-parser.js", function(exports, require, module){
  2616. var utils = require('./utils'),
  2617. STR_SAVE_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
  2618. STR_RESTORE_RE = /"(\d+)"/g,
  2619. NEWLINE_RE = /\n/g,
  2620. CTOR_RE = new RegExp('constructor'.split('').join('[\'"+, ]*')),
  2621. UNICODE_RE = /\\u\d\d\d\d/
  2622. // Variable extraction scooped from https://github.com/RubyLouvre/avalon
  2623. var KEYWORDS =
  2624. // keywords
  2625. 'break,case,catch,continue,debugger,default,delete,do,else,false' +
  2626. ',finally,for,function,if,in,instanceof,new,null,return,switch,this' +
  2627. ',throw,true,try,typeof,var,void,while,with,undefined' +
  2628. // reserved
  2629. ',abstract,boolean,byte,char,class,const,double,enum,export,extends' +
  2630. ',final,float,goto,implements,import,int,interface,long,native' +
  2631. ',package,private,protected,public,short,static,super,synchronized' +
  2632. ',throws,transient,volatile' +
  2633. // ECMA 5 - use strict
  2634. ',arguments,let,yield' +
  2635. // allow using Math in expressions
  2636. ',Math',
  2637. KEYWORDS_RE = new RegExp(["\\b" + KEYWORDS.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g'),
  2638. REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+|[\{,]\s*[\w\$_]+\s*:/g,
  2639. SPLIT_RE = /[^\w$]+/g,
  2640. NUMBER_RE = /\b\d[^,]*/g,
  2641. BOUNDARY_RE = /^,+|,+$/g
  2642. /**
  2643. * Strip top level variable names from a snippet of JS expression
  2644. */
  2645. function getVariables (code) {
  2646. code = code
  2647. .replace(REMOVE_RE, '')
  2648. .replace(SPLIT_RE, ',')
  2649. .replace(KEYWORDS_RE, '')
  2650. .replace(NUMBER_RE, '')
  2651. .replace(BOUNDARY_RE, '')
  2652. return code
  2653. ? code.split(/,+/)
  2654. : []
  2655. }
  2656. /**
  2657. * A given path could potentially exist not on the
  2658. * current compiler, but up in the parent chain somewhere.
  2659. * This function generates an access relationship string
  2660. * that can be used in the getter function by walking up
  2661. * the parent chain to check for key existence.
  2662. *
  2663. * It stops at top parent if no vm in the chain has the
  2664. * key. It then creates any missing bindings on the
  2665. * final resolved vm.
  2666. */
  2667. function traceScope (path, compiler, data) {
  2668. var rel = '',
  2669. dist = 0,
  2670. self = compiler
  2671. if (data && utils.get(data, path) !== undefined) {
  2672. // hack: temporarily attached data
  2673. return '$temp.'
  2674. }
  2675. while (compiler) {
  2676. if (compiler.hasKey(path)) {
  2677. break
  2678. } else {
  2679. compiler = compiler.parent
  2680. dist++
  2681. }
  2682. }
  2683. if (compiler) {
  2684. while (dist--) {
  2685. rel += '$parent.'
  2686. }
  2687. if (!compiler.bindings[path] && path.charAt(0) !== '$') {
  2688. compiler.createBinding(path)
  2689. }
  2690. } else {
  2691. self.createBinding(path)
  2692. }
  2693. return rel
  2694. }
  2695. /**
  2696. * Create a function from a string...
  2697. * this looks like evil magic but since all variables are limited
  2698. * to the VM's data it's actually properly sandboxed
  2699. */
  2700. function makeGetter (exp, raw) {
  2701. var fn
  2702. try {
  2703. fn = new Function(exp)
  2704. } catch (e) {
  2705. utils.warn('Error parsing expression: ' + raw)
  2706. }
  2707. return fn
  2708. }
  2709. /**
  2710. * Escape a leading dollar sign for regex construction
  2711. */
  2712. function escapeDollar (v) {
  2713. return v.charAt(0) === '$'
  2714. ? '\\' + v
  2715. : v
  2716. }
  2717. /**
  2718. * Parse and return an anonymous computed property getter function
  2719. * from an arbitrary expression, together with a list of paths to be
  2720. * created as bindings.
  2721. */
  2722. exports.parse = function (exp, compiler, data) {
  2723. // unicode and 'constructor' are not allowed for XSS security.
  2724. if (UNICODE_RE.test(exp) || CTOR_RE.test(exp)) {
  2725. utils.warn('Unsafe expression: ' + exp)
  2726. return
  2727. }
  2728. // extract variable names
  2729. var vars = getVariables(exp)
  2730. if (!vars.length) {
  2731. return makeGetter('return ' + exp, exp)
  2732. }
  2733. vars = utils.unique(vars)
  2734. var accessors = '',
  2735. has = utils.hash(),
  2736. strings = [],
  2737. // construct a regex to extract all valid variable paths
  2738. // ones that begin with "$" are particularly tricky
  2739. // because we can't use \b for them
  2740. pathRE = new RegExp(
  2741. "[^$\\w\\.](" +
  2742. vars.map(escapeDollar).join('|') +
  2743. ")[$\\w\\.]*\\b", 'g'
  2744. ),
  2745. body = (' ' + exp)
  2746. .replace(STR_SAVE_RE, saveStrings)
  2747. .replace(pathRE, replacePath)
  2748. .replace(STR_RESTORE_RE, restoreStrings)
  2749. body = accessors + 'return ' + body
  2750. function saveStrings (str) {
  2751. var i = strings.length
  2752. // escape newlines in strings so the expression
  2753. // can be correctly evaluated
  2754. strings[i] = str.replace(NEWLINE_RE, '\\n')
  2755. return '"' + i + '"'
  2756. }
  2757. function replacePath (path) {
  2758. // keep track of the first char
  2759. var c = path.charAt(0)
  2760. path = path.slice(1)
  2761. var val = 'this.' + traceScope(path, compiler, data) + path
  2762. if (!has[path]) {
  2763. accessors += val + ';'
  2764. has[path] = 1
  2765. }
  2766. // don't forget to put that first char back
  2767. return c + val
  2768. }
  2769. function restoreStrings (str, i) {
  2770. return strings[i]
  2771. }
  2772. return makeGetter(body, exp)
  2773. }
  2774. /**
  2775. * Evaluate an expression in the context of a compiler.
  2776. * Accepts additional data.
  2777. */
  2778. exports.eval = function (exp, compiler, data) {
  2779. var getter = exports.parse(exp, compiler, data), res
  2780. if (getter) {
  2781. // hack: temporarily attach the additional data so
  2782. // it can be accessed in the getter
  2783. compiler.vm.$temp = data
  2784. res = getter.call(compiler.vm)
  2785. delete compiler.vm.$temp
  2786. }
  2787. return res
  2788. }
  2789. });
  2790. require.register("vue/src/template-parser.js", function(exports, require, module){
  2791. var toFragment = require('./fragment');
  2792. /**
  2793. * Parses a template string or node and normalizes it into a
  2794. * a node that can be used as a partial of a template option
  2795. *
  2796. * Possible values include
  2797. * id selector: '#some-template-id'
  2798. * template string: '<div><span>my template</span></div>'
  2799. * DocumentFragment object
  2800. * Node object of type Template
  2801. */
  2802. module.exports = function(template) {
  2803. var templateNode;
  2804. if (template instanceof window.DocumentFragment) {
  2805. // if the template is already a document fragment -- do nothing
  2806. return template
  2807. }
  2808. if (typeof template === 'string') {
  2809. // template by ID
  2810. if (template.charAt(0) === '#') {
  2811. templateNode = document.getElementById(template.slice(1))
  2812. if (!templateNode) return
  2813. } else {
  2814. return toFragment(template)
  2815. }
  2816. } else if (template.nodeType) {
  2817. templateNode = template
  2818. } else {
  2819. return
  2820. }
  2821. // if its a template tag and the browser supports it,
  2822. // its content is already a document fragment!
  2823. if (templateNode.tagName === 'TEMPLATE' && templateNode.content) {
  2824. return templateNode.content
  2825. }
  2826. if (templateNode.tagName === 'SCRIPT') {
  2827. return toFragment(templateNode.innerHTML)
  2828. }
  2829. return toFragment(templateNode.outerHTML);
  2830. }
  2831. });
  2832. require.register("vue/src/text-parser.js", function(exports, require, module){
  2833. var openChar = '{',
  2834. endChar = '}',
  2835. ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g,
  2836. // lazy require
  2837. Directive
  2838. exports.Regex = buildInterpolationRegex()
  2839. function buildInterpolationRegex () {
  2840. var open = escapeRegex(openChar),
  2841. end = escapeRegex(endChar)
  2842. return new RegExp(open + open + open + '?(.+?)' + end + '?' + end + end)
  2843. }
  2844. function escapeRegex (str) {
  2845. return str.replace(ESCAPE_RE, '\\$&')
  2846. }
  2847. function setDelimiters (delimiters) {
  2848. openChar = delimiters[0]
  2849. endChar = delimiters[1]
  2850. exports.delimiters = delimiters
  2851. exports.Regex = buildInterpolationRegex()
  2852. }
  2853. /**
  2854. * Parse a piece of text, return an array of tokens
  2855. * token types:
  2856. * 1. plain string
  2857. * 2. object with key = binding key
  2858. * 3. object with key & html = true
  2859. */
  2860. function parse (text) {
  2861. if (!exports.Regex.test(text)) return null
  2862. var m, i, token, match, tokens = []
  2863. /* jshint boss: true */
  2864. while (m = text.match(exports.Regex)) {
  2865. i = m.index
  2866. if (i > 0) tokens.push(text.slice(0, i))
  2867. token = { key: m[1].trim() }
  2868. match = m[0]
  2869. token.html =
  2870. match.charAt(2) === openChar &&
  2871. match.charAt(match.length - 3) === endChar
  2872. tokens.push(token)
  2873. text = text.slice(i + m[0].length)
  2874. }
  2875. if (text.length) tokens.push(text)
  2876. return tokens
  2877. }
  2878. /**
  2879. * Parse an attribute value with possible interpolation tags
  2880. * return a Directive-friendly expression
  2881. *
  2882. * e.g. a {{b}} c => "a " + b + " c"
  2883. */
  2884. function parseAttr (attr) {
  2885. Directive = Directive || require('./directive')
  2886. var tokens = parse(attr)
  2887. if (!tokens) return null
  2888. if (tokens.length === 1) return tokens[0].key
  2889. var res = [], token
  2890. for (var i = 0, l = tokens.length; i < l; i++) {
  2891. token = tokens[i]
  2892. res.push(
  2893. token.key
  2894. ? inlineFilters(token.key)
  2895. : ('"' + token + '"')
  2896. )
  2897. }
  2898. return res.join('+')
  2899. }
  2900. /**
  2901. * Inlines any possible filters in a binding
  2902. * so that we can combine everything into a huge expression
  2903. */
  2904. function inlineFilters (key) {
  2905. if (key.indexOf('|') > -1) {
  2906. var dirs = Directive.parse(key),
  2907. dir = dirs && dirs[0]
  2908. if (dir && dir.filters) {
  2909. key = Directive.inlineFilters(
  2910. dir.key,
  2911. dir.filters
  2912. )
  2913. }
  2914. }
  2915. return '(' + key + ')'
  2916. }
  2917. exports.parse = parse
  2918. exports.parseAttr = parseAttr
  2919. exports.setDelimiters = setDelimiters
  2920. exports.delimiters = [openChar, endChar]
  2921. });
  2922. require.register("vue/src/deps-parser.js", function(exports, require, module){
  2923. var Emitter = require('./emitter'),
  2924. utils = require('./utils'),
  2925. Observer = require('./observer'),
  2926. catcher = new Emitter()
  2927. /**
  2928. * Auto-extract the dependencies of a computed property
  2929. * by recording the getters triggered when evaluating it.
  2930. */
  2931. function catchDeps (binding) {
  2932. if (binding.isFn) return
  2933. utils.log('\n- ' + binding.key)
  2934. var got = utils.hash()
  2935. binding.deps = []
  2936. catcher.on('get', function (dep) {
  2937. var has = got[dep.key]
  2938. if (
  2939. // avoid duplicate bindings
  2940. (has && has.compiler === dep.compiler) ||
  2941. // avoid repeated items as dependency
  2942. // only when the binding is from self or the parent chain
  2943. (dep.compiler.repeat && !isParentOf(dep.compiler, binding.compiler))
  2944. ) {
  2945. return
  2946. }
  2947. got[dep.key] = dep
  2948. utils.log(' - ' + dep.key)
  2949. binding.deps.push(dep)
  2950. dep.subs.push(binding)
  2951. })
  2952. binding.value.$get()
  2953. catcher.off('get')
  2954. }
  2955. /**
  2956. * Test if A is a parent of or equals B
  2957. */
  2958. function isParentOf (a, b) {
  2959. while (b) {
  2960. if (a === b) {
  2961. return true
  2962. }
  2963. b = b.parent
  2964. }
  2965. }
  2966. module.exports = {
  2967. /**
  2968. * the observer that catches events triggered by getters
  2969. */
  2970. catcher: catcher,
  2971. /**
  2972. * parse a list of computed property bindings
  2973. */
  2974. parse: function (bindings) {
  2975. utils.log('\nparsing dependencies...')
  2976. Observer.shouldGet = true
  2977. bindings.forEach(catchDeps)
  2978. Observer.shouldGet = false
  2979. utils.log('\ndone.')
  2980. }
  2981. }
  2982. });
  2983. require.register("vue/src/filters.js", function(exports, require, module){
  2984. var utils = require('./utils'),
  2985. get = utils.get,
  2986. slice = [].slice,
  2987. QUOTE_RE = /^'.*'$/,
  2988. filters = module.exports = utils.hash()
  2989. /**
  2990. * 'abc' => 'Abc'
  2991. */
  2992. filters.capitalize = function (value) {
  2993. if (!value && value !== 0) return ''
  2994. value = value.toString()
  2995. return value.charAt(0).toUpperCase() + value.slice(1)
  2996. }
  2997. /**
  2998. * 'abc' => 'ABC'
  2999. */
  3000. filters.uppercase = function (value) {
  3001. return (value || value === 0)
  3002. ? value.toString().toUpperCase()
  3003. : ''
  3004. }
  3005. /**
  3006. * 'AbC' => 'abc'
  3007. */
  3008. filters.lowercase = function (value) {
  3009. return (value || value === 0)
  3010. ? value.toString().toLowerCase()
  3011. : ''
  3012. }
  3013. /**
  3014. * 12345 => $12,345.00
  3015. */
  3016. filters.currency = function (value, sign) {
  3017. value = parseFloat(value)
  3018. if (!value && value !== 0) return ''
  3019. sign = sign || '$'
  3020. var s = Math.floor(value).toString(),
  3021. i = s.length % 3,
  3022. h = i > 0 ? (s.slice(0, i) + (s.length > 3 ? ',' : '')) : '',
  3023. f = '.' + value.toFixed(2).slice(-2)
  3024. return sign + h + s.slice(i).replace(/(\d{3})(?=\d)/g, '$1,') + f
  3025. }
  3026. /**
  3027. * args: an array of strings corresponding to
  3028. * the single, double, triple ... forms of the word to
  3029. * be pluralized. When the number to be pluralized
  3030. * exceeds the length of the args, it will use the last
  3031. * entry in the array.
  3032. *
  3033. * e.g. ['single', 'double', 'triple', 'multiple']
  3034. */
  3035. filters.pluralize = function (value) {
  3036. var args = slice.call(arguments, 1)
  3037. return args.length > 1
  3038. ? (args[value - 1] || args[args.length - 1])
  3039. : (args[value - 1] || args[0] + 's')
  3040. }
  3041. /**
  3042. * A special filter that takes a handler function,
  3043. * wraps it so it only gets triggered on specific keypresses.
  3044. *
  3045. * v-on only
  3046. */
  3047. var keyCodes = {
  3048. enter : 13,
  3049. tab : 9,
  3050. 'delete' : 46,
  3051. up : 38,
  3052. left : 37,
  3053. right : 39,
  3054. down : 40,
  3055. esc : 27
  3056. }
  3057. filters.key = function (handler, key) {
  3058. if (!handler) return
  3059. var code = keyCodes[key]
  3060. if (!code) {
  3061. code = parseInt(key, 10)
  3062. }
  3063. return function (e) {
  3064. if (e.keyCode === code) {
  3065. return handler.call(this, e)
  3066. }
  3067. }
  3068. }
  3069. /**
  3070. * Filter filter for v-repeat
  3071. */
  3072. filters.filterBy = function (arr, searchKey, delimiter, dataKey) {
  3073. // allow optional `in` delimiter
  3074. // because why not
  3075. if (delimiter && delimiter !== 'in') {
  3076. dataKey = delimiter
  3077. }
  3078. // get the search string
  3079. var search = stripQuotes(searchKey) || this.$get(searchKey)
  3080. if (!search) return arr
  3081. search = search.toLowerCase()
  3082. // get the optional dataKey
  3083. dataKey = dataKey && (stripQuotes(dataKey) || this.$get(dataKey))
  3084. // convert object to array
  3085. if (!Array.isArray(arr)) {
  3086. arr = utils.objectToArray(arr)
  3087. }
  3088. return arr.filter(function (item) {
  3089. return dataKey
  3090. ? contains(get(item, dataKey), search)
  3091. : contains(item, search)
  3092. })
  3093. }
  3094. filters.filterBy.computed = true
  3095. /**
  3096. * Sort fitler for v-repeat
  3097. */
  3098. filters.orderBy = function (arr, sortKey, reverseKey) {
  3099. var key = stripQuotes(sortKey) || this.$get(sortKey)
  3100. if (!key) return arr
  3101. // convert object to array
  3102. if (!Array.isArray(arr)) {
  3103. arr = utils.objectToArray(arr)
  3104. }
  3105. var order = 1
  3106. if (reverseKey) {
  3107. if (reverseKey === '-1') {
  3108. order = -1
  3109. } else if (reverseKey.charAt(0) === '!') {
  3110. reverseKey = reverseKey.slice(1)
  3111. order = this.$get(reverseKey) ? 1 : -1
  3112. } else {
  3113. order = this.$get(reverseKey) ? -1 : 1
  3114. }
  3115. }
  3116. // sort on a copy to avoid mutating original array
  3117. return arr.slice().sort(function (a, b) {
  3118. a = get(a, key)
  3119. b = get(b, key)
  3120. return a === b ? 0 : a > b ? order : -order
  3121. })
  3122. }
  3123. filters.orderBy.computed = true
  3124. // Array filter helpers -------------------------------------------------------
  3125. /**
  3126. * String contain helper
  3127. */
  3128. function contains (val, search) {
  3129. /* jshint eqeqeq: false */
  3130. if (utils.isObject(val)) {
  3131. for (var key in val) {
  3132. if (contains(val[key], search)) {
  3133. return true
  3134. }
  3135. }
  3136. } else if (val != null) {
  3137. return val.toString().toLowerCase().indexOf(search) > -1
  3138. }
  3139. }
  3140. /**
  3141. * Test whether a string is in quotes,
  3142. * if yes return stripped string
  3143. */
  3144. function stripQuotes (str) {
  3145. if (QUOTE_RE.test(str)) {
  3146. return str.slice(1, -1)
  3147. }
  3148. }
  3149. });
  3150. require.register("vue/src/transition.js", function(exports, require, module){
  3151. var endEvents = sniffEndEvents(),
  3152. config = require('./config'),
  3153. // batch enter animations so we only force the layout once
  3154. Batcher = require('./batcher'),
  3155. batcher = new Batcher(),
  3156. // cache timer functions
  3157. setTO = window.setTimeout,
  3158. clearTO = window.clearTimeout,
  3159. // exit codes for testing
  3160. codes = {
  3161. CSS_E : 1,
  3162. CSS_L : 2,
  3163. JS_E : 3,
  3164. JS_L : 4,
  3165. CSS_SKIP : -1,
  3166. JS_SKIP : -2,
  3167. JS_SKIP_E : -3,
  3168. JS_SKIP_L : -4,
  3169. INIT : -5,
  3170. SKIP : -6
  3171. }
  3172. // force layout before triggering transitions/animations
  3173. batcher._preFlush = function () {
  3174. /* jshint unused: false */
  3175. var f = document.body.offsetHeight
  3176. }
  3177. /**
  3178. * stage:
  3179. * 1 = enter
  3180. * 2 = leave
  3181. */
  3182. var transition = module.exports = function (el, stage, cb, compiler) {
  3183. var changeState = function () {
  3184. cb()
  3185. compiler.execHook(stage > 0 ? 'attached' : 'detached')
  3186. }
  3187. if (compiler.init) {
  3188. changeState()
  3189. return codes.INIT
  3190. }
  3191. var hasTransition = el.vue_trans === '',
  3192. hasAnimation = el.vue_anim === '',
  3193. effectId = el.vue_effect
  3194. if (effectId) {
  3195. return applyTransitionFunctions(
  3196. el,
  3197. stage,
  3198. changeState,
  3199. effectId,
  3200. compiler
  3201. )
  3202. } else if (hasTransition || hasAnimation) {
  3203. return applyTransitionClass(
  3204. el,
  3205. stage,
  3206. changeState,
  3207. hasAnimation
  3208. )
  3209. } else {
  3210. changeState()
  3211. return codes.SKIP
  3212. }
  3213. }
  3214. /**
  3215. * Togggle a CSS class to trigger transition
  3216. */
  3217. function applyTransitionClass (el, stage, changeState, hasAnimation) {
  3218. if (!endEvents.trans) {
  3219. changeState()
  3220. return codes.CSS_SKIP
  3221. }
  3222. // if the browser supports transition,
  3223. // it must have classList...
  3224. var onEnd,
  3225. classList = el.classList,
  3226. existingCallback = el.vue_trans_cb,
  3227. enterClass = config.enterClass,
  3228. leaveClass = config.leaveClass,
  3229. endEvent = hasAnimation ? endEvents.anim : endEvents.trans
  3230. // cancel unfinished callbacks and jobs
  3231. if (existingCallback) {
  3232. el.removeEventListener(endEvent, existingCallback)
  3233. classList.remove(enterClass)
  3234. classList.remove(leaveClass)
  3235. el.vue_trans_cb = null
  3236. }
  3237. if (stage > 0) { // enter
  3238. // set to enter state before appending
  3239. classList.add(enterClass)
  3240. // append
  3241. changeState()
  3242. // trigger transition
  3243. if (!hasAnimation) {
  3244. batcher.push({
  3245. execute: function () {
  3246. classList.remove(enterClass)
  3247. }
  3248. })
  3249. } else {
  3250. onEnd = function (e) {
  3251. if (e.target === el) {
  3252. el.removeEventListener(endEvent, onEnd)
  3253. el.vue_trans_cb = null
  3254. classList.remove(enterClass)
  3255. }
  3256. }
  3257. el.addEventListener(endEvent, onEnd)
  3258. el.vue_trans_cb = onEnd
  3259. }
  3260. return codes.CSS_E
  3261. } else { // leave
  3262. if (el.offsetWidth || el.offsetHeight) {
  3263. // trigger hide transition
  3264. classList.add(leaveClass)
  3265. onEnd = function (e) {
  3266. if (e.target === el) {
  3267. el.removeEventListener(endEvent, onEnd)
  3268. el.vue_trans_cb = null
  3269. // actually remove node here
  3270. changeState()
  3271. classList.remove(leaveClass)
  3272. }
  3273. }
  3274. // attach transition end listener
  3275. el.addEventListener(endEvent, onEnd)
  3276. el.vue_trans_cb = onEnd
  3277. } else {
  3278. // directly remove invisible elements
  3279. changeState()
  3280. }
  3281. return codes.CSS_L
  3282. }
  3283. }
  3284. function applyTransitionFunctions (el, stage, changeState, effectId, compiler) {
  3285. var funcs = compiler.getOption('effects', effectId)
  3286. if (!funcs) {
  3287. changeState()
  3288. return codes.JS_SKIP
  3289. }
  3290. var enter = funcs.enter,
  3291. leave = funcs.leave,
  3292. timeouts = el.vue_timeouts
  3293. // clear previous timeouts
  3294. if (timeouts) {
  3295. var i = timeouts.length
  3296. while (i--) {
  3297. clearTO(timeouts[i])
  3298. }
  3299. }
  3300. timeouts = el.vue_timeouts = []
  3301. function timeout (cb, delay) {
  3302. var id = setTO(function () {
  3303. cb()
  3304. timeouts.splice(timeouts.indexOf(id), 1)
  3305. if (!timeouts.length) {
  3306. el.vue_timeouts = null
  3307. }
  3308. }, delay)
  3309. timeouts.push(id)
  3310. }
  3311. if (stage > 0) { // enter
  3312. if (typeof enter !== 'function') {
  3313. changeState()
  3314. return codes.JS_SKIP_E
  3315. }
  3316. enter(el, changeState, timeout)
  3317. return codes.JS_E
  3318. } else { // leave
  3319. if (typeof leave !== 'function') {
  3320. changeState()
  3321. return codes.JS_SKIP_L
  3322. }
  3323. leave(el, changeState, timeout)
  3324. return codes.JS_L
  3325. }
  3326. }
  3327. /**
  3328. * Sniff proper transition end event name
  3329. */
  3330. function sniffEndEvents () {
  3331. var el = document.createElement('vue'),
  3332. defaultEvent = 'transitionend',
  3333. events = {
  3334. 'webkitTransition' : 'webkitTransitionEnd',
  3335. 'transition' : defaultEvent,
  3336. 'mozTransition' : defaultEvent
  3337. },
  3338. ret = {}
  3339. for (var name in events) {
  3340. if (el.style[name] !== undefined) {
  3341. ret.trans = events[name]
  3342. break
  3343. }
  3344. }
  3345. ret.anim = el.style.animation === ''
  3346. ? 'animationend'
  3347. : 'webkitAnimationEnd'
  3348. return ret
  3349. }
  3350. // Expose some stuff for testing purposes
  3351. transition.codes = codes
  3352. transition.sniff = sniffEndEvents
  3353. });
  3354. require.register("vue/src/batcher.js", function(exports, require, module){
  3355. var utils = require('./utils')
  3356. function Batcher () {
  3357. this.reset()
  3358. }
  3359. var BatcherProto = Batcher.prototype
  3360. BatcherProto.push = function (job) {
  3361. if (!job.id || !this.has[job.id]) {
  3362. this.queue.push(job)
  3363. this.has[job.id] = job
  3364. if (!this.waiting) {
  3365. this.waiting = true
  3366. utils.nextTick(utils.bind(this.flush, this))
  3367. }
  3368. } else if (job.override) {
  3369. var oldJob = this.has[job.id]
  3370. oldJob.cancelled = true
  3371. this.queue.push(job)
  3372. this.has[job.id] = job
  3373. }
  3374. }
  3375. BatcherProto.flush = function () {
  3376. // before flush hook
  3377. if (this._preFlush) this._preFlush()
  3378. // do not cache length because more jobs might be pushed
  3379. // as we execute existing jobs
  3380. for (var i = 0; i < this.queue.length; i++) {
  3381. var job = this.queue[i]
  3382. if (!job.cancelled) {
  3383. job.execute()
  3384. }
  3385. }
  3386. this.reset()
  3387. }
  3388. BatcherProto.reset = function () {
  3389. this.has = utils.hash()
  3390. this.queue = []
  3391. this.waiting = false
  3392. }
  3393. module.exports = Batcher
  3394. });
  3395. require.register("vue/src/directives/index.js", function(exports, require, module){
  3396. var utils = require('../utils'),
  3397. config = require('../config'),
  3398. transition = require('../transition'),
  3399. directives = module.exports = utils.hash()
  3400. /**
  3401. * Nest and manage a Child VM
  3402. */
  3403. directives.component = {
  3404. isLiteral: true,
  3405. bind: function () {
  3406. if (!this.el.vue_vm) {
  3407. this.childVM = new this.Ctor({
  3408. el: this.el,
  3409. parent: this.vm
  3410. })
  3411. }
  3412. },
  3413. unbind: function () {
  3414. if (this.childVM) {
  3415. this.childVM.$destroy()
  3416. }
  3417. }
  3418. }
  3419. /**
  3420. * Binding HTML attributes
  3421. */
  3422. directives.attr = {
  3423. bind: function () {
  3424. var params = this.vm.$options.paramAttributes
  3425. this.isParam = params && params.indexOf(this.arg) > -1
  3426. },
  3427. update: function (value) {
  3428. if (value || value === 0) {
  3429. this.el.setAttribute(this.arg, value)
  3430. } else {
  3431. this.el.removeAttribute(this.arg)
  3432. }
  3433. if (this.isParam) {
  3434. this.vm[this.arg] = utils.checkNumber(value)
  3435. }
  3436. }
  3437. }
  3438. /**
  3439. * Binding textContent
  3440. */
  3441. directives.text = {
  3442. bind: function () {
  3443. this.attr = this.el.nodeType === 3
  3444. ? 'nodeValue'
  3445. : 'textContent'
  3446. },
  3447. update: function (value) {
  3448. this.el[this.attr] = utils.guard(value)
  3449. }
  3450. }
  3451. /**
  3452. * Binding CSS display property
  3453. */
  3454. directives.show = function (value) {
  3455. var el = this.el,
  3456. target = value ? '' : 'none',
  3457. change = function () {
  3458. el.style.display = target
  3459. }
  3460. transition(el, value ? 1 : -1, change, this.compiler)
  3461. }
  3462. /**
  3463. * Binding CSS classes
  3464. */
  3465. directives['class'] = function (value) {
  3466. if (this.arg) {
  3467. utils[value ? 'addClass' : 'removeClass'](this.el, this.arg)
  3468. } else {
  3469. if (this.lastVal) {
  3470. utils.removeClass(this.el, this.lastVal)
  3471. }
  3472. if (value) {
  3473. utils.addClass(this.el, value)
  3474. this.lastVal = value
  3475. }
  3476. }
  3477. }
  3478. /**
  3479. * Only removed after the owner VM is ready
  3480. */
  3481. directives.cloak = {
  3482. isEmpty: true,
  3483. bind: function () {
  3484. var el = this.el
  3485. this.compiler.observer.once('hook:ready', function () {
  3486. el.removeAttribute(config.prefix + '-cloak')
  3487. })
  3488. }
  3489. }
  3490. /**
  3491. * Store a reference to self in parent VM's $
  3492. */
  3493. directives.ref = {
  3494. isLiteral: true,
  3495. bind: function () {
  3496. var id = this.expression
  3497. if (id) {
  3498. this.vm.$parent.$[id] = this.vm
  3499. }
  3500. },
  3501. unbind: function () {
  3502. var id = this.expression
  3503. if (id) {
  3504. delete this.vm.$parent.$[id]
  3505. }
  3506. }
  3507. }
  3508. directives.on = require('./on')
  3509. directives.repeat = require('./repeat')
  3510. directives.model = require('./model')
  3511. directives['if'] = require('./if')
  3512. directives['with'] = require('./with')
  3513. directives.html = require('./html')
  3514. directives.style = require('./style')
  3515. directives.partial = require('./partial')
  3516. directives.view = require('./view')
  3517. });
  3518. require.register("vue/src/directives/if.js", function(exports, require, module){
  3519. var utils = require('../utils')
  3520. /**
  3521. * Manages a conditional child VM
  3522. */
  3523. module.exports = {
  3524. bind: function () {
  3525. this.parent = this.el.parentNode
  3526. this.ref = document.createComment('vue-if')
  3527. this.Ctor = this.compiler.resolveComponent(this.el)
  3528. // insert ref
  3529. this.parent.insertBefore(this.ref, this.el)
  3530. this.parent.removeChild(this.el)
  3531. if (utils.attr(this.el, 'view')) {
  3532. utils.warn(
  3533. 'Conflict: v-if cannot be used together with v-view. ' +
  3534. 'Just set v-view\'s binding value to empty string to empty it.'
  3535. )
  3536. }
  3537. if (utils.attr(this.el, 'repeat')) {
  3538. utils.warn(
  3539. 'Conflict: v-if cannot be used together with v-repeat. ' +
  3540. 'Use `v-show` or the `filterBy` filter instead.'
  3541. )
  3542. }
  3543. },
  3544. update: function (value) {
  3545. if (!value) {
  3546. this.unbind()
  3547. } else if (!this.childVM) {
  3548. this.childVM = new this.Ctor({
  3549. el: this.el.cloneNode(true),
  3550. parent: this.vm
  3551. })
  3552. if (this.compiler.init) {
  3553. this.parent.insertBefore(this.childVM.$el, this.ref)
  3554. } else {
  3555. this.childVM.$before(this.ref)
  3556. }
  3557. }
  3558. },
  3559. unbind: function () {
  3560. if (this.childVM) {
  3561. this.childVM.$destroy()
  3562. this.childVM = null
  3563. }
  3564. }
  3565. }
  3566. });
  3567. require.register("vue/src/directives/repeat.js", function(exports, require, module){
  3568. var utils = require('../utils'),
  3569. config = require('../config')
  3570. /**
  3571. * Binding that manages VMs based on an Array
  3572. */
  3573. module.exports = {
  3574. bind: function () {
  3575. this.identifier = '$r' + this.id
  3576. // a hash to cache the same expressions on repeated instances
  3577. // so they don't have to be compiled for every single instance
  3578. this.expCache = utils.hash()
  3579. var el = this.el,
  3580. ctn = this.container = el.parentNode
  3581. // extract child Id, if any
  3582. this.childId = this.compiler.eval(utils.attr(el, 'ref'))
  3583. // create a comment node as a reference node for DOM insertions
  3584. this.ref = document.createComment(config.prefix + '-repeat-' + this.key)
  3585. ctn.insertBefore(this.ref, el)
  3586. ctn.removeChild(el)
  3587. this.collection = null
  3588. this.vms = null
  3589. },
  3590. update: function (collection) {
  3591. if (!Array.isArray(collection)) {
  3592. if (utils.isObject(collection)) {
  3593. collection = utils.objectToArray(collection)
  3594. } else {
  3595. utils.warn('v-repeat only accepts Array or Object values.')
  3596. }
  3597. }
  3598. // keep reference of old data and VMs
  3599. // so we can reuse them if possible
  3600. this.oldVMs = this.vms
  3601. this.oldCollection = this.collection
  3602. collection = this.collection = collection || []
  3603. var isObject = collection[0] && utils.isObject(collection[0])
  3604. this.vms = this.oldCollection
  3605. ? this.diff(collection, isObject)
  3606. : this.init(collection, isObject)
  3607. if (this.childId) {
  3608. this.vm.$[this.childId] = this.vms
  3609. }
  3610. },
  3611. init: function (collection, isObject) {
  3612. var vm, vms = []
  3613. for (var i = 0, l = collection.length; i < l; i++) {
  3614. vm = this.build(collection[i], i, isObject)
  3615. vms.push(vm)
  3616. if (this.compiler.init) {
  3617. this.container.insertBefore(vm.$el, this.ref)
  3618. } else {
  3619. vm.$before(this.ref)
  3620. }
  3621. }
  3622. return vms
  3623. },
  3624. /**
  3625. * Diff the new array with the old
  3626. * and determine the minimum amount of DOM manipulations.
  3627. */
  3628. diff: function (newCollection, isObject) {
  3629. var i, l, item, vm,
  3630. oldIndex,
  3631. targetNext,
  3632. currentNext,
  3633. nextEl,
  3634. ctn = this.container,
  3635. oldVMs = this.oldVMs,
  3636. vms = []
  3637. vms.length = newCollection.length
  3638. // first pass, collect new reused and new created
  3639. for (i = 0, l = newCollection.length; i < l; i++) {
  3640. item = newCollection[i]
  3641. if (isObject) {
  3642. item.$index = i
  3643. if (item.__emitter__ && item.__emitter__[this.identifier]) {
  3644. // this piece of data is being reused.
  3645. // record its final position in reused vms
  3646. item.$reused = true
  3647. } else {
  3648. vms[i] = this.build(item, i, isObject)
  3649. }
  3650. } else {
  3651. // we can't attach an identifier to primitive values
  3652. // so have to do an indexOf...
  3653. oldIndex = indexOf(oldVMs, item)
  3654. if (oldIndex > -1) {
  3655. // record the position on the existing vm
  3656. oldVMs[oldIndex].$reused = true
  3657. oldVMs[oldIndex].$data.$index = i
  3658. } else {
  3659. vms[i] = this.build(item, i, isObject)
  3660. }
  3661. }
  3662. }
  3663. // second pass, collect old reused and destroy unused
  3664. for (i = 0, l = oldVMs.length; i < l; i++) {
  3665. vm = oldVMs[i]
  3666. item = this.arg
  3667. ? vm.$data[this.arg]
  3668. : vm.$data
  3669. if (item.$reused) {
  3670. vm.$reused = true
  3671. delete item.$reused
  3672. }
  3673. if (vm.$reused) {
  3674. // update the index to latest
  3675. vm.$index = item.$index
  3676. // the item could have had a new key
  3677. if (item.$key && item.$key !== vm.$key) {
  3678. vm.$key = item.$key
  3679. }
  3680. vms[vm.$index] = vm
  3681. } else {
  3682. // this one can be destroyed.
  3683. if (item.__emitter__) {
  3684. delete item.__emitter__[this.identifier]
  3685. }
  3686. vm.$destroy()
  3687. }
  3688. }
  3689. // final pass, move/insert DOM elements
  3690. i = vms.length
  3691. while (i--) {
  3692. vm = vms[i]
  3693. item = vm.$data
  3694. targetNext = vms[i + 1]
  3695. if (vm.$reused) {
  3696. nextEl = vm.$el.nextSibling
  3697. // destroyed VMs' element might still be in the DOM
  3698. // due to transitions
  3699. while (!nextEl.vue_vm && nextEl !== this.ref) {
  3700. nextEl = nextEl.nextSibling
  3701. }
  3702. currentNext = nextEl.vue_vm
  3703. if (currentNext !== targetNext) {
  3704. if (!targetNext) {
  3705. ctn.insertBefore(vm.$el, this.ref)
  3706. } else {
  3707. nextEl = targetNext.$el
  3708. // new VMs' element might not be in the DOM yet
  3709. // due to transitions
  3710. while (!nextEl.parentNode) {
  3711. targetNext = vms[nextEl.vue_vm.$index + 1]
  3712. nextEl = targetNext
  3713. ? targetNext.$el
  3714. : this.ref
  3715. }
  3716. ctn.insertBefore(vm.$el, nextEl)
  3717. }
  3718. }
  3719. delete vm.$reused
  3720. delete item.$index
  3721. delete item.$key
  3722. } else { // a new vm
  3723. vm.$before(targetNext ? targetNext.$el : this.ref)
  3724. }
  3725. }
  3726. return vms
  3727. },
  3728. build: function (data, index, isObject) {
  3729. // wrap non-object values
  3730. var raw, alias,
  3731. wrap = !isObject || this.arg
  3732. if (wrap) {
  3733. raw = data
  3734. alias = this.arg || '$value'
  3735. data = {}
  3736. data[alias] = raw
  3737. }
  3738. data.$index = index
  3739. var el = this.el.cloneNode(true),
  3740. Ctor = this.compiler.resolveComponent(el, data),
  3741. vm = new Ctor({
  3742. el: el,
  3743. data: data,
  3744. parent: this.vm,
  3745. compilerOptions: {
  3746. repeat: true,
  3747. expCache: this.expCache
  3748. }
  3749. })
  3750. if (isObject) {
  3751. // attach an ienumerable identifier to the raw data
  3752. (raw || data).__emitter__[this.identifier] = true
  3753. }
  3754. return vm
  3755. },
  3756. unbind: function () {
  3757. if (this.childId) {
  3758. delete this.vm.$[this.childId]
  3759. }
  3760. if (this.vms) {
  3761. var i = this.vms.length
  3762. while (i--) {
  3763. this.vms[i].$destroy()
  3764. }
  3765. }
  3766. }
  3767. }
  3768. // Helpers --------------------------------------------------------------------
  3769. /**
  3770. * Find an object or a wrapped data object
  3771. * from an Array
  3772. */
  3773. function indexOf (vms, obj) {
  3774. for (var vm, i = 0, l = vms.length; i < l; i++) {
  3775. vm = vms[i]
  3776. if (!vm.$reused && vm.$value === obj) {
  3777. return i
  3778. }
  3779. }
  3780. return -1
  3781. }
  3782. });
  3783. require.register("vue/src/directives/on.js", function(exports, require, module){
  3784. var utils = require('../utils')
  3785. /**
  3786. * Binding for event listeners
  3787. */
  3788. module.exports = {
  3789. isFn: true,
  3790. bind: function () {
  3791. this.context = this.binding.isExp
  3792. ? this.vm
  3793. : this.binding.compiler.vm
  3794. if (this.el.tagName === 'IFRAME' && this.arg !== 'load') {
  3795. var self = this
  3796. this.iframeBind = function () {
  3797. self.el.contentWindow.addEventListener(self.arg, self.handler)
  3798. }
  3799. this.el.addEventListener('load', this.iframeBind)
  3800. }
  3801. },
  3802. update: function (handler) {
  3803. if (typeof handler !== 'function') {
  3804. utils.warn('Directive "v-on:' + this.expression + '" expects a method.')
  3805. return
  3806. }
  3807. this.reset()
  3808. var vm = this.vm,
  3809. context = this.context
  3810. this.handler = function (e) {
  3811. e.targetVM = vm
  3812. context.$event = e
  3813. var res = handler.call(context, e)
  3814. context.$event = null
  3815. return res
  3816. }
  3817. if (this.iframeBind) {
  3818. this.iframeBind()
  3819. } else {
  3820. this.el.addEventListener(this.arg, this.handler)
  3821. }
  3822. },
  3823. reset: function () {
  3824. var el = this.iframeBind
  3825. ? this.el.contentWindow
  3826. : this.el
  3827. if (this.handler) {
  3828. el.removeEventListener(this.arg, this.handler)
  3829. }
  3830. },
  3831. unbind: function () {
  3832. this.reset()
  3833. this.el.removeEventListener('load', this.iframeBind)
  3834. }
  3835. }
  3836. });
  3837. require.register("vue/src/directives/model.js", function(exports, require, module){
  3838. var utils = require('../utils'),
  3839. isIE9 = navigator.userAgent.indexOf('MSIE 9.0') > 0,
  3840. filter = [].filter
  3841. /**
  3842. * Returns an array of values from a multiple select
  3843. */
  3844. function getMultipleSelectOptions (select) {
  3845. return filter
  3846. .call(select.options, function (option) {
  3847. return option.selected
  3848. })
  3849. .map(function (option) {
  3850. return option.value || option.text
  3851. })
  3852. }
  3853. /**
  3854. * Two-way binding for form input elements
  3855. */
  3856. module.exports = {
  3857. bind: function () {
  3858. var self = this,
  3859. el = self.el,
  3860. type = el.type,
  3861. tag = el.tagName
  3862. self.lock = false
  3863. self.ownerVM = self.binding.compiler.vm
  3864. // determine what event to listen to
  3865. self.event =
  3866. (self.compiler.options.lazy ||
  3867. tag === 'SELECT' ||
  3868. type === 'checkbox' || type === 'radio')
  3869. ? 'change'
  3870. : 'input'
  3871. // determine the attribute to change when updating
  3872. self.attr = type === 'checkbox'
  3873. ? 'checked'
  3874. : (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA')
  3875. ? 'value'
  3876. : 'innerHTML'
  3877. // select[multiple] support
  3878. if(tag === 'SELECT' && el.hasAttribute('multiple')) {
  3879. this.multi = true
  3880. }
  3881. var compositionLock = false
  3882. self.cLock = function () {
  3883. compositionLock = true
  3884. }
  3885. self.cUnlock = function () {
  3886. compositionLock = false
  3887. }
  3888. el.addEventListener('compositionstart', this.cLock)
  3889. el.addEventListener('compositionend', this.cUnlock)
  3890. // attach listener
  3891. self.set = self.filters
  3892. ? function () {
  3893. if (compositionLock) return
  3894. // if this directive has filters
  3895. // we need to let the vm.$set trigger
  3896. // update() so filters are applied.
  3897. // therefore we have to record cursor position
  3898. // so that after vm.$set changes the input
  3899. // value we can put the cursor back at where it is
  3900. var cursorPos
  3901. try { cursorPos = el.selectionStart } catch (e) {}
  3902. self._set()
  3903. // since updates are async
  3904. // we need to reset cursor position async too
  3905. utils.nextTick(function () {
  3906. if (cursorPos !== undefined) {
  3907. el.setSelectionRange(cursorPos, cursorPos)
  3908. }
  3909. })
  3910. }
  3911. : function () {
  3912. if (compositionLock) return
  3913. // no filters, don't let it trigger update()
  3914. self.lock = true
  3915. self._set()
  3916. utils.nextTick(function () {
  3917. self.lock = false
  3918. })
  3919. }
  3920. el.addEventListener(self.event, self.set)
  3921. // fix shit for IE9
  3922. // since it doesn't fire input on backspace / del / cut
  3923. if (isIE9) {
  3924. self.onCut = function () {
  3925. // cut event fires before the value actually changes
  3926. utils.nextTick(function () {
  3927. self.set()
  3928. })
  3929. }
  3930. self.onDel = function (e) {
  3931. if (e.keyCode === 46 || e.keyCode === 8) {
  3932. self.set()
  3933. }
  3934. }
  3935. el.addEventListener('cut', self.onCut)
  3936. el.addEventListener('keyup', self.onDel)
  3937. }
  3938. },
  3939. _set: function () {
  3940. this.ownerVM.$set(
  3941. this.key, this.multi
  3942. ? getMultipleSelectOptions(this.el)
  3943. : this.el[this.attr]
  3944. )
  3945. },
  3946. update: function (value, init) {
  3947. /* jshint eqeqeq: false */
  3948. // sync back inline value if initial data is undefined
  3949. if (init && value === undefined) {
  3950. return this._set()
  3951. }
  3952. if (this.lock) return
  3953. var el = this.el
  3954. if (el.tagName === 'SELECT') { // select dropdown
  3955. el.selectedIndex = -1
  3956. if(this.multi && Array.isArray(value)) {
  3957. value.forEach(this.updateSelect, this)
  3958. } else {
  3959. this.updateSelect(value)
  3960. }
  3961. } else if (el.type === 'radio') { // radio button
  3962. el.checked = value == el.value
  3963. } else if (el.type === 'checkbox') { // checkbox
  3964. el.checked = !!value
  3965. } else {
  3966. el[this.attr] = utils.guard(value)
  3967. }
  3968. },
  3969. updateSelect: function (value) {
  3970. /* jshint eqeqeq: false */
  3971. // setting <select>'s value in IE9 doesn't work
  3972. // we have to manually loop through the options
  3973. var options = this.el.options,
  3974. i = options.length
  3975. while (i--) {
  3976. if (options[i].value == value) {
  3977. options[i].selected = true
  3978. break
  3979. }
  3980. }
  3981. },
  3982. unbind: function () {
  3983. var el = this.el
  3984. el.removeEventListener(this.event, this.set)
  3985. el.removeEventListener('compositionstart', this.cLock)
  3986. el.removeEventListener('compositionend', this.cUnlock)
  3987. if (isIE9) {
  3988. el.removeEventListener('cut', this.onCut)
  3989. el.removeEventListener('keyup', this.onDel)
  3990. }
  3991. }
  3992. }
  3993. });
  3994. require.register("vue/src/directives/with.js", function(exports, require, module){
  3995. var utils = require('../utils')
  3996. /**
  3997. * Binding for inheriting data from parent VMs.
  3998. */
  3999. module.exports = {
  4000. bind: function () {
  4001. var self = this,
  4002. childKey = self.arg,
  4003. parentKey = self.key,
  4004. compiler = self.compiler,
  4005. owner = self.binding.compiler
  4006. if (compiler === owner) {
  4007. this.alone = true
  4008. return
  4009. }
  4010. if (childKey) {
  4011. if (!compiler.bindings[childKey]) {
  4012. compiler.createBinding(childKey)
  4013. }
  4014. // sync changes on child back to parent
  4015. compiler.observer.on('change:' + childKey, function (val) {
  4016. if (compiler.init) return
  4017. if (!self.lock) {
  4018. self.lock = true
  4019. utils.nextTick(function () {
  4020. self.lock = false
  4021. })
  4022. }
  4023. owner.vm.$set(parentKey, val)
  4024. })
  4025. }
  4026. },
  4027. update: function (value) {
  4028. // sync from parent
  4029. if (!this.alone && !this.lock) {
  4030. if (this.arg) {
  4031. this.vm.$set(this.arg, value)
  4032. } else if (this.vm.$data !== value) {
  4033. this.vm.$data = value
  4034. }
  4035. }
  4036. }
  4037. }
  4038. });
  4039. require.register("vue/src/directives/html.js", function(exports, require, module){
  4040. var utils = require('../utils'),
  4041. slice = [].slice
  4042. /**
  4043. * Binding for innerHTML
  4044. */
  4045. module.exports = {
  4046. bind: function () {
  4047. // a comment node means this is a binding for
  4048. // {{{ inline unescaped html }}}
  4049. if (this.el.nodeType === 8) {
  4050. // hold nodes
  4051. this.nodes = []
  4052. }
  4053. },
  4054. update: function (value) {
  4055. value = utils.guard(value)
  4056. if (this.nodes) {
  4057. this.swap(value)
  4058. } else {
  4059. this.el.innerHTML = value
  4060. }
  4061. },
  4062. swap: function (value) {
  4063. var parent = this.el.parentNode,
  4064. nodes = this.nodes,
  4065. i = nodes.length
  4066. // remove old nodes
  4067. while (i--) {
  4068. parent.removeChild(nodes[i])
  4069. }
  4070. // convert new value to a fragment
  4071. var frag = utils.toFragment(value)
  4072. // save a reference to these nodes so we can remove later
  4073. this.nodes = slice.call(frag.childNodes)
  4074. parent.insertBefore(frag, this.el)
  4075. }
  4076. }
  4077. });
  4078. require.register("vue/src/directives/style.js", function(exports, require, module){
  4079. var prefixes = ['-webkit-', '-moz-', '-ms-']
  4080. /**
  4081. * Binding for CSS styles
  4082. */
  4083. module.exports = {
  4084. bind: function () {
  4085. var prop = this.arg
  4086. if (!prop) return
  4087. if (prop.charAt(0) === '$') {
  4088. // properties that start with $ will be auto-prefixed
  4089. prop = prop.slice(1)
  4090. this.prefixed = true
  4091. }
  4092. this.prop = prop
  4093. },
  4094. update: function (value) {
  4095. var prop = this.prop,
  4096. isImportant
  4097. /* jshint eqeqeq: true */
  4098. // cast possible numbers/booleans into strings
  4099. if (value != null) value += ''
  4100. if (prop) {
  4101. if (value) {
  4102. isImportant = value.slice(-10) === '!important'
  4103. ? 'important'
  4104. : ''
  4105. if (isImportant) {
  4106. value = value.slice(0, -10).trim()
  4107. }
  4108. }
  4109. this.el.style.setProperty(prop, value, isImportant)
  4110. if (this.prefixed) {
  4111. var i = prefixes.length
  4112. while (i--) {
  4113. this.el.style.setProperty(prefixes[i] + prop, value, isImportant)
  4114. }
  4115. }
  4116. } else {
  4117. this.el.style.cssText = value
  4118. }
  4119. }
  4120. }
  4121. });
  4122. require.register("vue/src/directives/partial.js", function(exports, require, module){
  4123. var utils = require('../utils')
  4124. /**
  4125. * Binding for partials
  4126. */
  4127. module.exports = {
  4128. isLiteral: true,
  4129. bind: function () {
  4130. var id = this.expression
  4131. if (!id) return
  4132. var el = this.el,
  4133. compiler = this.compiler,
  4134. partial = compiler.getOption('partials', id)
  4135. if (!partial) {
  4136. if (id === 'yield') {
  4137. utils.warn('{{>yield}} syntax has been deprecated. Use <content> tag instead.')
  4138. }
  4139. return
  4140. }
  4141. partial = partial.cloneNode(true)
  4142. // comment ref node means inline partial
  4143. if (el.nodeType === 8) {
  4144. // keep a ref for the partial's content nodes
  4145. var nodes = [].slice.call(partial.childNodes),
  4146. parent = el.parentNode
  4147. parent.insertBefore(partial, el)
  4148. parent.removeChild(el)
  4149. // compile partial after appending, because its children's parentNode
  4150. // will change from the fragment to the correct parentNode.
  4151. // This could affect directives that need access to its element's parentNode.
  4152. nodes.forEach(compiler.compile, compiler)
  4153. } else {
  4154. // just set innerHTML...
  4155. el.innerHTML = ''
  4156. el.appendChild(partial)
  4157. }
  4158. }
  4159. }
  4160. });
  4161. require.register("vue/src/directives/view.js", function(exports, require, module){
  4162. /**
  4163. * Manages a conditional child VM using the
  4164. * binding's value as the component ID.
  4165. */
  4166. module.exports = {
  4167. bind: function () {
  4168. // track position in DOM with a ref node
  4169. var el = this.raw = this.el,
  4170. parent = el.parentNode,
  4171. ref = this.ref = document.createComment('v-view')
  4172. parent.insertBefore(ref, el)
  4173. parent.removeChild(el)
  4174. // cache original content
  4175. /* jshint boss: true */
  4176. var node,
  4177. frag = this.inner = document.createElement('div')
  4178. while (node = el.firstChild) {
  4179. frag.appendChild(node)
  4180. }
  4181. },
  4182. update: function(value) {
  4183. this.unbind()
  4184. var Ctor = this.compiler.getOption('components', value)
  4185. if (!Ctor) return
  4186. this.childVM = new Ctor({
  4187. el: this.raw.cloneNode(true),
  4188. parent: this.vm,
  4189. compilerOptions: {
  4190. rawContent: this.inner.cloneNode(true)
  4191. }
  4192. })
  4193. this.el = this.childVM.$el
  4194. if (this.compiler.init) {
  4195. this.ref.parentNode.insertBefore(this.el, this.ref)
  4196. } else {
  4197. this.childVM.$before(this.ref)
  4198. }
  4199. },
  4200. unbind: function() {
  4201. if (this.childVM) {
  4202. this.childVM.$destroy()
  4203. }
  4204. }
  4205. }
  4206. });
  4207. require.alias("vue/src/main.js", "vue/index.js");
  4208. if (typeof exports == 'object') {
  4209. module.exports = require('vue');
  4210. } else if (typeof define == 'function' && define.amd) {
  4211. define(function(){ return require('vue'); });
  4212. } else {
  4213. window['Vue'] = require('vue');
  4214. }})();