From ab63c58e9ee8f078adf6da3a6723da92e603c740 Mon Sep 17 00:00:00 2001 From: Chao Liu Date: Wed, 29 Aug 2012 04:33:45 +0800 Subject: [PATCH 01/35] [Property View] Fix bug: Grid uses two types of form widget for interger --- src/js/views/property.js | 28 +++++++++++++++++++++++++++- src/js/widgets.js | 25 +++++++++++++++++-------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/js/views/property.js b/src/js/views/property.js index 909830ae..9334c0eb 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -113,7 +113,8 @@ design = ADM.getDesignRoot(), title = this.element.parent().find('.property_title'), content = this.element.find('.property_content'), - continueToDelete, buttonsContainer, container, prerequisite; + continueToDelete, buttonsContainer, container, prerequisite, + range, min, max; // Clear the properties pane when nothing is selected if (node === null || node === undefined) { @@ -181,6 +182,31 @@ value.find("#" + valueId).attr("checked", "checked"); } break; + case "integer": + range = BWidget.getPropertyRange(type, p); + if (range) { + min = range.split('-')[0]; + max = range.split('-')[1]; + $('') + .addClass('title labelInput') + .attr({ + id: valueId, + min: min, + max: max + }) + .change(function(event) { + if( parseInt(this.value) > parseInt(this.max) || + parseInt(this.value) < parseInt(this.min)) { + $(this).effect("highlight", {color: "red"}, 1000); + event.stopImmediatePropagation(); + this.value = valueVal; + } + }) + .appendTo(value); + //set default value + value.find('#' + valueId).val(valueVal); + } + break; case "url-uploadable": $('') .attr('id', valueId) diff --git a/src/js/widgets.js b/src/js/widgets.js index b3a75eba..0cb888f1 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1754,18 +1754,12 @@ var BWidgetRegistry = { rows: { type: "integer", defaultValue: 1, + range: "1-100", setPropertyHook: function (node, value, transactionData) { var rows, columns, i, block, map, children, blocks, count, blockIndex, root; rows = node.getProperty("rows"); columns = node.getProperty("columns"); - - // FIXME: really this should be enforced in the property - // pane, or elsewhere; this won't really work - if (value < 1) { - value = 1; - } - root = node.getDesign(); root.suppressEvents(true); @@ -1819,8 +1813,8 @@ var BWidgetRegistry = { }, columns: { type: "integer", - options: [ 2, 3, 4, 5 ], defaultValue: 2, + range: "2-5", setPropertyHook: function (node, value, transactionData) { var rows, columns, i, block, map, children, blocks, count, index, blockIndex, root; @@ -2560,6 +2554,21 @@ var BWidget = { return schema; }, + /** + * Gets the range for a given property. + * + * @param {String} widgetType The type of the widget. + * @param {String} property The name of the requested property. + * @return {String} The range for the given property + */ + getPropertyRange: function (widgetType, property) { + var schema = BWidget.getPropertySchema(widgetType, property); + if (schema) { + return schema.range; + } + return schema; + }, + /** * Applies any value mapping on the given value that would occur during * serialization if this value were found in the given widget type and From 25f3a0afd770f3a19eced5a479a51d91ee8aa9d3 Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Tue, 31 Jul 2012 16:01:02 +0800 Subject: [PATCH 02/35] [Widgets] Add list widgets --- src/assets/groups.json | 23 +- src/css/images/widgets/jqm_button_list.svg | 44 ++ .../images/widgets/jqm_button_list_item.svg | 28 + src/css/images/widgets/jqm_icon_list.svg | Bin 0 -> 4010 bytes .../images/widgets/jqm_icon_list_button.svg | 26 + src/css/images/widgets/jqm_icon_list_item.svg | Bin 0 -> 2444 bytes .../images/widgets/jqm_icon_split_list.svg | Bin 0 -> 4034 bytes .../widgets/jqm_icon_split_list_item.svg | Bin 0 -> 2468 bytes src/css/images/widgets/jqm_list.svg | 2 +- src/css/images/widgets/jqm_list_item.svg | 2 +- .../images/widgets/jqm_list_split_button.svg | 31 - .../images/widgets/jqm_simple_split_list.svg | Bin 0 -> 4042 bytes .../widgets/jqm_simple_split_list_item.svg | Bin 0 -> 2464 bytes src/css/images/widgets/jqm_text_list.svg | 44 ++ .../images/widgets/jqm_text_list_button.svg | Bin 0 -> 2818 bytes src/css/images/widgets/jqm_text_list_item.svg | 28 + .../images/widgets/jqm_text_split_list.svg | Bin 0 -> 4034 bytes .../widgets/jqm_text_split_list_item.svg | Bin 0 -> 2458 bytes src/css/images/widgets/jqm_thumbnail_list.svg | Bin 0 -> 4026 bytes .../widgets/jqm_thumbnail_list_button.svg | 26 + .../widgets/jqm_thumbnail_list_item.svg | 24 + .../widgets/jqm_thumbnail_split_list.svg | Bin 0 -> 4054 bytes .../widgets/jqm_thumbnail_split_list_item.svg | 24 + src/js/composer.js | 1 + src/js/widgets.js | 573 ++++++++++++++++-- 25 files changed, 779 insertions(+), 97 deletions(-) create mode 100644 src/css/images/widgets/jqm_button_list.svg create mode 100644 src/css/images/widgets/jqm_button_list_item.svg create mode 100644 src/css/images/widgets/jqm_icon_list.svg create mode 100644 src/css/images/widgets/jqm_icon_list_button.svg create mode 100644 src/css/images/widgets/jqm_icon_list_item.svg create mode 100644 src/css/images/widgets/jqm_icon_split_list.svg create mode 100644 src/css/images/widgets/jqm_icon_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_list_split_button.svg create mode 100644 src/css/images/widgets/jqm_simple_split_list.svg create mode 100644 src/css/images/widgets/jqm_simple_split_list_item.svg create mode 100644 src/css/images/widgets/jqm_text_list.svg create mode 100644 src/css/images/widgets/jqm_text_list_button.svg create mode 100644 src/css/images/widgets/jqm_text_list_item.svg create mode 100644 src/css/images/widgets/jqm_text_split_list.svg create mode 100644 src/css/images/widgets/jqm_text_split_list_item.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list_button.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_list_item.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_split_list.svg create mode 100644 src/css/images/widgets/jqm_thumbnail_split_list_item.svg diff --git a/src/assets/groups.json b/src/assets/groups.json index bb05bd01..90c81f47 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -21,8 +21,27 @@ "Boolean": ["#0._hidden_node.jqm_input_boolean"] } ], - "List Views": [ - "List", "OrderedList", "ListItem", "ListDivider", "ListButton" + "List Views": [ { + "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], + "Unordered Lists": [ { + "Single Lists": [ { + "Simple Single List": ["SimpleList", "SimpleListItem", "ListDivider"], + "Button Single List": ["ButtonList", "ButtonListItem", "ListButton", "ListDivider"], + "Text Single List": ["TextList", "TextListItem", "ListDivider", "TextButton"], + "Icon Single List": ["IconList", "IconListItem", "IconButton", "ListDivider"], + "Thumbnail Single List": ["ThumbnailList", "ThumbnailListItem", "ThumbnailButton", "ListDivider"] + } + ], + "Split Lists": [ { + "Simple Split List": ["SimpleSplitList", "SimpleSplitListItem"], + "Text Split List": ["TextSplitList", "TextSplitListItem", "TextButton"], + "Icon Split List": ["IconSplitList", "IconSplitListItem", "IconButton"], + "Thumbnail Split List": ["ThumbnailSplitList", "ThumbnailSplitListItem", "ThumbnailButton"] + } + ] + } + ] + } ], "Image": ["Image"] } diff --git a/src/css/images/widgets/jqm_button_list.svg b/src/css/images/widgets/jqm_button_list.svg new file mode 100644 index 00000000..647be337 --- /dev/null +++ b/src/css/images/widgets/jqm_button_list.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +Button List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_button_list_item.svg b/src/css/images/widgets/jqm_button_list_item.svg new file mode 100644 index 00000000..097e1803 --- /dev/null +++ b/src/css/images/widgets/jqm_button_list_item.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + +Button List Item + diff --git a/src/css/images/widgets/jqm_icon_list.svg b/src/css/images/widgets/jqm_icon_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..af655fe436b3cc60e9b6fe080629e0ffc403db47 GIT binary patch literal 4010 zcmeHK?@tp!5Pe@U@qakr1DZ(7wNS9u--wc^kRTdk41rQ;wG=D`ipGCkeQ)Nrz0)fc zqu&fjgWY0}#|trruG z#eqh*R7^aJO}Y8NqgrOzb)!g#5}4UTG0GBUY8haJ;AH2 zmMS&2E&89w))?ciJ;l^s*D9ap7@@xTdTtuSSXrFl3C?IuF=^Utj1raxJDNOei?P$#E zT0GKKM*7G!G|c7^wKOPGO)G=LyzX+e#~IIaM1N`=^_V~TF_ikuBtEb@m+_dj`IzsD zj%L!&BkB`odOXEm;zNXQxog9|?2ZG*tW6K9)Vs!W2yYwIr23iVTZ0&FSw!26%DoFU zAM?a@({#eOHf~{t*eI~B{5x0{E=Jqh;fZ9cz*7n5Gq^p%?)Qv0AMr62!J?<0Ch4NOX&4^YNmA2(`8Y`(s)st7BlIPXt6m14v7YEix+p4fq7wxlT2+7)7 zFxh2x(r0qyHki?F!cJmRWm)G8EaJSk%4!pfY?&3IVVm&^t2eo)#a+%TC;U}~ZwzXG zjq{r(RV@0{BYal)6yScJC$a_O%$VPIjls3Ll(X7pT2-)!l({3IX@X4Q=sBbZs_jE& zP3UUSM`s!NF~pZ-8fpD3^Qk;@9IJkd}VAamrPzJi^i;=Cco#%;@YvqzNZ~w-Pe?Nif2GT z7T*^|IUft9|BeO6ht8s?IdVp0!I4v9G?b4}8P`b2B0*6a4++ZeRgoawfzuWFzeR$) zRArY2NRT8C2@A;@Uq7Ehf@X$D&}cLgdSu2vF&ptCW><$-NA9x2iyIFN(Oq(UpPf7A zI^ogpJ${2K(7y#rDwON)tvhnX#va4a-~BEUZWhu#Ge*CkNpcqMGx|U9l|E~~?#aq% z=vSZch5l}FEFSOhP1qI>Z}Fopr5lwHvYM=j7$;vLeh9G$ojLG@@_BWZDATIE`+ptN zd*HYoQ~VG*rfw0}JfRzg*HOA-Do*3^gfe_pp7>WCQ(k5}rX+bhQDRq+{LhZ5nITVT MG@2*Ezd)~=Uk>gw$p8QV literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_icon_list_button.svg b/src/css/images/widgets/jqm_icon_list_button.svg new file mode 100644 index 00000000..53c6e1f2 --- /dev/null +++ b/src/css/images/widgets/jqm_icon_list_button.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + +Icon List Button + + + diff --git a/src/css/images/widgets/jqm_icon_list_item.svg b/src/css/images/widgets/jqm_icon_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..c95fe613c3f0b33ecfd8848f292088d15ea7be72 GIT binary patch literal 2444 zcma);Yfn=_5Qg8cnD`%#@BvAr<+O^W);nHER7enwF@``XP$>mV!J_f6tIxZ8mbRoQ z*_@u;nc2C%GpB!kH}qHo9jc>DXKJaZ6SZ}ut{!Syxk_5#ox$m<34I4{S9^hbs=jtL zkJKVEkM&45bwdr^(y~_dT<`TsYkI-$6LjzKUeku2>5W$4X55)qne|as&fYC^XBp1A zKIj#1+s^~%h28}}rnQgNzK&H7^zZU2@l^Re!v8(!uXt}EvyZn;td|Ro=7ux%27Birf1BuX#$r~xSTO%OURTJqSMq9HOC61!ko|*e zYs|G2R(a%Z)M}p=$j~78dLA^Uv#U5o1mCgdoa_f~u8L|GH};9OO|Bi6byY`rXK-5F zenve8h2{)vuBUZmK{}yoOWVZN0t?&Zu&D#I_PBWp&SGx6L0i-?NlVOholGAG4Xt4F z7%eSm#6;Q=lV(a~f@GvE zA$J$K1v)-qeTqJg*gnFxk#|H+jr|th#Tj4^hUhoVC(F-M1!KTdwXPW=9N5#FarWd)8^;)DoO3gdtJEVi#W!MD*|{Kl8D$H)ALy4+7HgDH z=Dd3vd3ui9n<-{;oXqwnPPw<#&R>8#@Xx~THI%!2376!Zd6}YAj#MpBt3kGc6<5B7 zbd7J3rK8Lbd`&(%hpEr5?y^Ph-VaZ0Li`b(mt*(zAGOm5Ujt&#c-$GDVxBrZrkD|S z7&6nNM+Qu%9684pXS=@=OPngK5}w>cca7N->oz)N)6BHS*=tO)*-JY7Pv-}o`o8}G z*h1>^ulk0Uo1EPPU3NyFF>IRSGq)f1{%W}6RtnjS3PjlqT9kF}Q&xs^DE`BU=f9l? BUa9~9 literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_icon_split_list.svg b/src/css/images/widgets/jqm_icon_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..7293b6dfbb1f73a8ff2078382627d39cdd3fb9ad GIT binary patch literal 4034 zcmeHKT~8BH5IwJ$_#YN{Koe=%77Et-jVOr<38FE^5GaLKOTkj0X#DHyIWv3PUEM-4 z`bKWHyLax~nYr_E=Jw~08XlsL1GEw06b*E7j1~^j!F^02MgentM_lQkPWmoaJJ`3? z6ZEi$S#nj#^AHbk6E{%9B$ly;r+9<+SjRK&KBnw_zSpsdCwPffu14H5iz3H6lsVVe zGWRTVWdm>VoNwumZRHtWn;lbVQfm)Ks2cqY8U;RO{vOi)ebS%vy-l7bt*ujgF_Bmt zNOVob#Io4vyOg_2E#Vx&>U_V%W>1Sdpezkx6Kn&Lc``kfxkg1c!0m~`VzvUgR zq{k!5Q_b{vioL{!2;Xvf!@lf}1Ny8@3#yd6#&f9NHYiE?Gs~|AYqVt^ZPP3FE|h%C z6W2}B3BTI7g&EdHfqCV>L9^;&w5}bVNV*C+)fi$!8}stj!;b#L<+B-Lt3ERK4jEX zT@BjkC?h+D^(C5S;-6)lm1V;1DyDhv;TT5javhGi!dZoYA%5l~bZO6pxS@*Oid11bJz^N>F^SS_zUJFkPPi+e(m? z%Iwmh5=63+>(FTsYq0m+oMy?;gMP7A9};5khsR*(3TV> zlXhq3+|PN>+5Pjop~o8NP#tADQ%gOasI4P)^-$BwRnh{_3`$o`?suSewHK(T>T6f? za4o{~SdVm5H`LHAEo)WJ^Ldb!Y8zR(ygl?%`E zaKD4z9jv4{lGl^-k_UgMK_WIs@IRaCo>*eBLDxprLERUM(7L1`iV zjCu?T%^B8QPwU76cS6;cwu!3+7PiS@QwM16A$bbUVs5)ZThuT~OU!hgOdkggtzh#Q zEiLYhX;*Mq*Bwr~P-2}k{AqCNQ$PDLyp5Dw`V2ak^%QJAW$)~mGP<6i&pp#8irvD8 zOg|^`Cb@BmLvq%^gF1RwiNpQ2jwa)0o?VL`ZHJ6@$jXC%YCa+2X3%uXuA|$Ur8i38 zD*h+S?u)B!Z4;4gm59oHKC8Ja?EV__=8L|J!g)r#y|q^$UEiLf;6t_IH3D_s}A%qeP&H#HbM8EHRGXFePFa|tT>zX0r;Tq=i|2CrU z*R$~w8|gP{!Lb^Bdp}^s}&g&COljgiG?yv`mpJhpQHDtAV$I6<59n zca3+Exg*aHd`&(%hpEr5?y^N>?}uM)Li`b(mt*(zAGOm5Ujt&#__;GY#XNO-Ofe(u zFl44jj|`YjIed;S&UU{gmN->dB|N!@?i#Zv)@^jkrkQDtv)7npvzK)EOXmlkTHap( zwvf8~tG?moCTI6Rm!01(Mqr=4pT@K4j@6v~u=g9p-M3Q6`CBH*WmG20WzeIXYm%}x LoKNw~BcA^P0)t~= literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_list.svg b/src/css/images/widgets/jqm_list.svg index ff9dd70b..4481b865 100644 --- a/src/css/images/widgets/jqm_list.svg +++ b/src/css/images/widgets/jqm_list.svg @@ -32,7 +32,7 @@ -Unordered List +Simple List diff --git a/src/css/images/widgets/jqm_list_item.svg b/src/css/images/widgets/jqm_list_item.svg index 7703f1a0..00d56daa 100644 --- a/src/css/images/widgets/jqm_list_item.svg +++ b/src/css/images/widgets/jqm_list_item.svg @@ -24,5 +24,5 @@ -List Item +Simple List Item diff --git a/src/css/images/widgets/jqm_list_split_button.svg b/src/css/images/widgets/jqm_list_split_button.svg deleted file mode 100644 index 2411051f..00000000 --- a/src/css/images/widgets/jqm_list_split_button.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - -List Split Button - - - - diff --git a/src/css/images/widgets/jqm_simple_split_list.svg b/src/css/images/widgets/jqm_simple_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..1542ca00d31cb6be251f3c765a1f62d6c6855d92 GIT binary patch literal 4042 zcmeHKT~8BH5IwJ$_#akyKoe=%77Et-jbDk138FE^G*A{=DFsWxqVcb*=gjPFcXf-! z=$qMWcX#f+GjnI=oVoq}t${lj;s9MlI7Na!j?uv(dbovI#3*5r&xj*Ev?$-~BY#0&Fd7HwJ`;0Se-e}b+O?<#)}>Hi+(kNMok3}w zwbZGxYti4IT4RhGc9k=0U8{UrWQ2z1>zQc`-^$_)ckqeU6qB}%#;9O*w4%+ub{K2z zOS)FDG#WeQNW#_knU7(rIifY?Q#vA>9ja;z+uT>eTG(a`TiB=8K3ATw&OEj~)8-nA zw0NZJjP#LdNX+IDwIr0Orj@~QUU&Gl%Ms6WM1LCm8ZdwIV=VQND|pB1T*E!q<~_bE zIvUAdcd1X98E_Z7sSgpp6wVFn@+%G)vo1ZTQ|~(WA-ru+lj>)IZwWElv50mVm7C{k zKIV>Frs;%lU0lUHu~A}O`ERf+TuipL%^k^BiMtZc=W%U<-LE-s-s62Hh7GIcd~7Al z=b*uyd)#N33+1gvn-Q%lDqYLx93EvZRZmfUN?uf(v$Pp-T^?DRY^%mfU9o%B5R$jG zY_i|k$?nOKn=qsOl%2$+%ChzuSj2hnDXUE^(ljeV!xrNeW^Zy$hpU`dPWV)XZ;Wbx zo#UG(RV;?oBYf6)mEeA#rLtw?%$UD7jKMX#QZUzMXZV`U%~w}Uu3Rzs&lMJvW%E9Z@x;)1dvnJ6&i(FJxoYw%Su|z^wfVb97T1bZ_C2i#^FC+1Q#=C# z^7uY4%Eefy{BtZgKC~A_&5<)13yz!$qoI6+%J`3jJQ5V8>5!oOUK9z^9XMT)|5GH$ zOI3Ddgak>7kg%N2@%c*`Bxq!e1bt0L!hp;;BxWPtVs>?Sb>u!fytwhe5Zx!o581h6 z&J!N}+~X&x68&4Iq(-^U-Z~@K?Av1)`n#V+!pTCq=cnlR^J&h)c}D*SKGSEd*Ev}k z4gKl^KGNSNchKSUi2Rw@m)_K)n)VbgH+f5<8A8lPW`)lCVMW9^cC0^$KSHcR=MH?L zd|#YJs`NtM|GSRrJ#yNPD*gx^Ri}*qJfahb*IBlsDo)e!h%$Up9{F1xRbJ*hsw71` ZQeoGS{MU}Ekui_xYch|7e~Df-KLD+@Izj*d literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_simple_split_list_item.svg b/src/css/images/widgets/jqm_simple_split_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..d3304a98acc6cbe53ff90d56e320bbcc28977284 GIT binary patch literal 2464 zcma);YflqV5QgU~CjN&7KA?%TY|Ew8dP6RfpqL;UV@LyKfodsO3KWcgU47m;J#O8xEB3+tn6M+PcJ0)vet&6N1%74zPw@Yc`!$}s@EqZ71M9`U#^Q~} zV5!*mEcN?+^zLIN#u2?9otM=8X(FLaZD8-p^H)cgG8VGh#)9Y%@w!B=wW3$UTB>Ml zdG>!iSYv97zKS{7pjAH2kfEOYdgU79Sydb(f=jF^Cr3_Atz?xOi6dfdl552!UF96@ z0!oJT67}fyH78h8J*6XY?ue>g+asX|dqgB#1)@@)PubHu?EW6|X2*7NIjlLFhjXjD;TqJadC2=1wNTv} z*i5jhthBtIleU^$LeD6C>V6b9C$Jg&x_D!4*ly^qjI4M16GYQam5?v7)5C092NCM@ zy7!L|yGu-wdmEW1Qlaq?_=xo}`Z!?w1lvO12{{$^GrS8kKpqUxuREQ@KTQ>c0ZrAaO%m~74f6Sa z8^QO7*;vI!{N-&3GxybJ6net!Ntrf^G0ZsSW*AqoM<)C4h(TqaI`3_i&Det9-$q%e zQAC;Yu4$y{Ic#sTKa;~`mN#L_y{C4113ZI%;k$R-%yd|ut z@)fu%yo4L8wu_yf08Jc36Ivu8% z5O(aD>ChuRrc(-^VhgifZ;3@tB~}4X=FnYX_Jq3Sr)->=(m3^iNj7y$hrV>K@l^8q z0+5B+<=^cmUe@uu$@3KKWq#65on7~*FkSbv=5w8sXyR1|ZslYXs?zk%O8ELwevUy% P(Ra$!U^a!Xj&S}5h + + + + + + + + + + + + + + + + + + + + + + + + + +Text List + + + + + + + + + diff --git a/src/css/images/widgets/jqm_text_list_button.svg b/src/css/images/widgets/jqm_text_list_button.svg new file mode 100644 index 0000000000000000000000000000000000000000..7bee4b5c75126c39415cf10c19424ae7eb78aeb5 GIT binary patch literal 2818 zcma);ZBH9l5QXO}k@6oF_&_7YHfvL2J5JIN@+Q#|320SS$O2=)!5C@`F^Tfm+dgOR zUhmqN6s_#tojZ44&YYRM|NhgmS2nhD>sw+s*0rHsSWpIsucDHtBPqAgvK80ty_%ms^S6}e8HPAIrY`ls#c%uI3?E} zSSv5tsuk95Sn0BRgL;fJ%L(38PuWOZJF@D)4#}$v7Y@O&V`o?$vhy0A1#AayEm)Xm zB_Q1d=}WiJb)T15=^_)SRl&TjN4y=g66%}~Pm8w^^-~fr=A&+#c>uxV&CTK#(mQ}&cUot1WoL2lZX0k2TS5liKi|-+H*wvpz{2OmaoXT zf2AYLT{AeRrrsd)fe~sIwT|cDwCD^e8ryJQ5{e~u zdYDZgVT3xp?foOh9*|Si-eXUXU7`1{xr>E66Mk;9zUNZKJI0QBXq~HUKfA@-Oje_B z%5+VfDb+ceLDoQT4ZT%5K5~75J`UWzz_*xp0jA=9m*~O_Py{*qCDWVqOH@G|&{S>O zG8yMrj_3dT2(drR$2)w)U(ts+^P~FAV^5epDbq$dh8ZVprg;^6WH~z{^2$DO-C35c z+B28WvMkgnvP`&Z8fkh?`&-Uta+u7DCQP|sshv)Mr>x)j(+4DLoP-V2lhzUoS}9s} zm)2ajiWgPBj&_~1NZLW?E3w9ygkkKn`@3wNz0dqtpOb%J=WOnp{zX3{_%$Z?gr7P? zQ%qB5$P^R9&K;Q{Ju+rGrRXWQFxz!X)Zuc&Gj1TS`q{3p44u=VDshH|c^jvvY_B|E zrmc8pxea~ud?jY>7mlh*?Dx<1H}ST~B;?d~9*WIvPAq)`sapoFp`OMz zPC9+Z&3YMlCW=4I1f9cYXbG3Q^H(`Vjnd3CuHLax@)JxM>rCopZ$-ovo1%(yQ<-TZ riVt-dF9wJmns8+}QDat0syB6tzAVC?r*Ni + + + + + + + + + + + + + + + + + +Text List Item + diff --git a/src/css/images/widgets/jqm_text_split_list.svg b/src/css/images/widgets/jqm_text_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..f9faa17851670501c6f06466ce6fbbad9ff96f9e GIT binary patch literal 4034 zcmeHKT~8BH5IwJ$_#YN{Koe=%77Et-ji?C<37|2?5GaLKOTkj0X#DHyIWv3PUEN|a z@@6*OkGc2G%$=EY=Jv<;8XlsLL$nd$3=MQ~f) zQ}nQpSw=X}b3Y$MO`+WeS8lU92;M%Co!&{g2C%=;1jKcM_MpF5n>q_=fiFD4p` z1C4H}n0OYOe2;qfXeI0;c%2`Y*!*d6g(9^|dlweJZR%3QJgOa9(D*oBml$hZ!Ku+*s@lOW_tju6>@tRRe4^GaSDv!YJhmOv<{I*} zc%-Y0^s#AZn9XBqX;7w`RtAT8-Q(9jM?B9F{i*S*$Nb5Uq0~nv@t)PWjK{3a$9z|G zG?Km^QJ*l=<1Y3SA0m9sog3C=R~#~CZF*3p-Zkz+c-x>R)z2*78pLSJBHCtD?p><+ zggdUArc=JPaSJoVMuBzZ_h4DL7;S5pJCdyecO{(9;Pwc+-!k5Oz=u=}YgWzK*h-eo zL5(^0xKA(_%3GZ_BU)8d+Lq60tfVegPhNdWo>!Ywv>9++99SD|tHMfMwBM2;Bx`HI zWPh@g-jgG@!Hjkjb`p~+%i3pP5$C;^tTwU8wpkGxb{MZPdy8vYT;;rS%BL!PV^I5R z9N#jjV$r7_;j_Z40QdVMku4Z!#=PG(2G{IT&TN-yR>2}t=8Ax(2{MJF=ZGGtwvU)K zp{qe3on_?55MPq%OY>)$XH}VayNYSN;W?sspTNnaTQ z&*6^c{ES~^yx@JF{Z@YKU0o=G&x~#6lF7?t(U=v~Fqkuw?#j+_#sp?rkO_>Y7v5)`HJkf8it6$#QEI9-wdTO`O! zRd#8B1WEFcu#n90`SU3xXk>^4eT_y!kIdL7W+VQ@?CS99$X#}LapR#Ox=W7lvvbFs zCp`MO$4^iN`nNzyg>s#}bw;k(x5qH_cR!1SlZAB8jM49BlAML}jQ$UNq0d^cbFwlT z`qf8#roY?ViSKEfdpR~1?NKV6i<333j-}I;(6Tv*fV!4uDH^NEZ1G0W7dm#}5#{;n z>`|r%^7{HZsrSZlJE?dhbW)uz{_}@U9$sJRPO3PK#~;e@Rr%vzby9hm?WB_A@kfc> WLh|1`sYZtUp|8>W5&j)|)%*l^(m1#P literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_text_split_list_item.svg b/src/css/images/widgets/jqm_text_split_list_item.svg new file mode 100644 index 0000000000000000000000000000000000000000..30788fadd0c37e034412b28c3750c87a108b6f58 GIT binary patch literal 2458 zcma);TTc^F6ouC-CjN&J9?(Qurd2Gp-VrrXF+nuOm6pepf{nj~iXiJKc zlXhnI{j&C+`SZJ>M;dBhU1d5^TYVj=qXYHyK(oqK(jwOkPERf9+i-i@4cuc5w4(*2 zmXLX*hq|t7YUqYmw5DfzuTOfX=V%{cdzb4wZRn|9>lNG#oduOSA64bqcPr?uz**M^ zz2Iv9dEh+P+YraB_V7B;q3VHtDxVU+D*p$>zYF~Z*G**hh_;3Ia$&K2ZZUc)7m?+G zzKz{&yreu*)YI#dhj=<@xKgk2cNXf`#Fi@-tJ=eZ`B#a$LalvLRFhWfSnP)Cf4j29 zT+88<$8@7r$FxX=h9TCoU@<+ri!)?!iZ|C}FK}~JR6Ez$Bi9bKc3!qs9pjzAX`}s= zehdrC8Q$Da+sJ}+Le-|W$g2$&wy0rC->}+8^BA1P+V+CAXknU_Sm`>IJ`5Jx!RH}X z+R%(?cW~6#ZJu`E#6D-l)8J`9{~X7N8aX%g8Fa4b3D|tXy{lu+_<4*y&&+@ z{hTVB^d>d-sacl@>eyW)56{~=mW-bT?%K>~CsedcRqp@O@(~%gf~8~by1J=(W}^hI z;(zk&xwzcd78%)BiL5;5^SX73-(M5ae9@P&8a4u&Cu?ikWDgqjJl1`NUbt^9d}erc zRl1>{b6OocM$a^Snm!Giv-nJNT|W0V={HVSo2vJV4dQL*PB@k{>2Wu`0ui3{W|$u% zc9Wcv^aeT|wBqa^b2SRr&+)kieVf>vd2N=!}KDU~Ubk+zK7 z9po07_=NQt<~U;e0N+O50W~%D+e8<4fFl^8-!wm2et|9+1Kz52&5`lwjOzJ+A2If; z`B=qA`i=WAX8zTmY3PZ&CuiF@$GGEMn@L=y8JR2I5u?uD3bGebwy1l7ei3D{M+s%F zySI_I=cK>6VkgJV>}cYadqeO12DlCXB;37(a)&qJvV3P=rYMyoRSVQ=kgedwov$HX z<6UIwDD#6@Q%tU5nzPHNYzf_a;a8iIe?;fS+`awB{S3g@klZtVo(yj>Z=F6{%m~{L zmFY7hL$*_noO6r2-EWCyo+_LYk=(_0jolObHoj%k&a}n(D{Qj)3pV_v^MgpO?=Jv* zNK^h*--)tG{4tXz85{-#4xk!|#&eUaC8DJ7{RZ*$y)X3qEtB*zzI&pyJCQ7pwo?4w Hh|hlkF6&|4 literal 0 HcmV?d00001 diff --git a/src/css/images/widgets/jqm_thumbnail_list.svg b/src/css/images/widgets/jqm_thumbnail_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..a1da7b67416594f97bcb8f47a487a4520c6ce4b2 GIT binary patch literal 4026 zcmeHKYflqV5ItWp@joo^0ZpW3TPRrT1H@ONVuEOlF$7AXl~S;@STz21^_-c#?XGUI z82M&4-N)Q}XXeh#Idl8tdkyz7z!BPraE1oDI7JJ`=-@795Tk$vJ|m8FP^Wy4qa7UB zXdgZ7W1h1roO2)da2?lB!!*{hfrogFcX)+ITzyL22YkN57S`|_&o~-!%{+>{-lEKJ zy{&W2I!89~22c2u{n$nx;idU8gC?!^aDuAIKSNi6zcTN~^#6eJCw%U3PLtl&X}y?e zEDklgrDEb)Z1O$o-J_MTkKlEFTw?R5#TAOwbJ{z%_-#{{BIZ%;(1OM%@w&uV>k3|F zwN$CGZP7oRSYwRab`?`=U8{UrV1x$d>$zzR-^$_?ckr3k6qBZn#wcNBxT49uwis*e zOS+b^I2=3UNQ0}_n2$lCIifY?Q#vA>9ja;vyWCfUwXn+=)^SL!U9Rl2&OEjq)8-oT zw0NYejP!|VXqe3tYH3iWnpOr!dEMjJK1V#y5&fz0tH=DwkCD_zrtzNDxsFxV<|^M6 z9gU=~2h=Cb^tg-t#D@r9bLWP2*%e2OS(_eIsdt0>5Z*SaN%b?&w+1oVvWT`Bl{*(| zKIM++#%3Kl9G)1Ox^c>Rz)%G#7 zCUiCEqqB_s7~xAYeQEwY^Q8Fw-pk7*JxnlA%Su|z^HF;kki)+OS`<_;Wd0$fADV_lV zS$tm<<$NrZt{e-F5A8)!bL5Q2f+MHIXeb|{GX5hWiv&e!G9)O!mqmhf2ToVy{}u`I zQk7jAB0-WoBrGL!eEwnz2^tw8L0{vM&?7Srh}nogF}pgvI&zmCUfg(Oi0+c(2khK2 z=LwH~?(q{;f&MK~QlVUDZ=I1V_U$nY{oT(Z;bbA*a})IYxg=-dJfr^uU+A;e>zu5N zhJN)CpXl$lF;JgxyWGtVN4Jeh#m5>`x6;W + + + + + + + + + + + + + + + + +Thumbnail List Button + + + diff --git a/src/css/images/widgets/jqm_thumbnail_list_item.svg b/src/css/images/widgets/jqm_thumbnail_list_item.svg new file mode 100644 index 00000000..659e8a8b --- /dev/null +++ b/src/css/images/widgets/jqm_thumbnail_list_item.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + +Thumbnail List Item + diff --git a/src/css/images/widgets/jqm_thumbnail_split_list.svg b/src/css/images/widgets/jqm_thumbnail_split_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..309ee41939927dbb677eef4545e58bf03e604b80 GIT binary patch literal 4054 zcmeHKYflqV5ItWp@joo^0ZpW3TPRrT1H@ONVuEOlF$7AXl~S;@STz21^_-c#?XGUI z82M&4-N)Q}XXeh#Idl8tdkyz7z!BPraE1oDI7JJ`=-@795Tk$vJ|m8FP^Wy4qa7UB zXdgZ7W1h1roO2)da2?lB!!*{hfrogFcX)+ITzyL22YkN57S`|_&o~-!%{+>{-lEKJ zy{&W2I!89~22c2u{n$nx;idU8gC?!^aDuAIKSNi6zcTN~^#6eJCw%U3PLtl&X}y?e zEDklgrDEb)Z1O$o-J_MTkKlEFTw?R5#TAOwbJ{z%_-#{{BIZ%;(1OM%@w&uV>k3|F zwN$CGZP7oRSYwRab`?`=U8{UrV1x$d>$zzR-^$_?ckr3k6qBZn#wcNBxT49uwis*e zOS+b^I2=3UNQ0}_n2$lCIifY?Q#vA>9ja;vyWCfUwXn+=)^SL!U9Rl2&OEjq)8-oT zw0NYejP!|VXqe3tYH3iWnpOr!dEMjJK1V#y5&fz0tH=DwkCD_zrtzNDxsFxV<|^M6 z9gU=~2h=Cb^tg-t#D@r9bLWP2*%e2OS(_eIsdt0>5Z*SaN%b?&w+1oVvWT`Bl{*(| zKIM++#%3Kl9G)1Ox^c>Rz)%G#7 zCUiCEqqB_s7~xAYeQEwY^Q8Fw-pk7*JxnlA%Su|z^HF;kki)+OS`<_;Wd0$fADV_lV zS$tm<<$NrZt{e-F5A8)!bL5Q2f+MHIXeb|{GX5hWiv&e!G9)O!mqmhf2ToVy{}u`I zQk7jAB0-WoBrGL!eEwnz2^tw8L0{vM&?7Srh}nogF}pgvI&zmCUfg(Oi0+c(2khK2 z=LwH~?(q{;f&MK~QlVUDZ=I1V_U$nY{oT(Z;bbA*a})IYxg=-dJfr^uU+A;e>zu5N zhJN)CpXl$lF;JgxyWGtVN86O?G$y3?_^zkeSu-WkIZL>C%@}6a>FgiYMU1Jh6PJXz zg)SbrMY+E`qm=23c5-#y)%)e7-Bnx?x~onc|2ajc5wE#)cU7Dw;}m81vYhg-x~sg* ec2`OAIHkl6BKhy#RU;!#(bsrR3I7 + + + + + + + + + + + + + + + + +Thumbnail Split List Item + diff --git a/src/js/composer.js b/src/js/composer.js index 36618177..c1eb7178 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -558,6 +558,7 @@ $(function() { '> .ui-collapsible-content > .adm-node,' + '> ul > li.adm-node,' + '> div > .adm-node,' + + '> div > div > a > .adm-node,' + '> *.orig-adm-node:not(.ui-header,.ui-content,.ui-footer)', start: function(event, ui){ trackOffsets('start: ',ui,$(this).data('sortable')); diff --git a/src/js/widgets.js b/src/js/widgets.js index de12b02d..b0c7b2d7 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -25,6 +25,11 @@ var BCommonProperties = { defaultValue: false, htmlAttribute: "disabled" }, + filter: { + type: "boolean", + defaultValue: false, + htmlAttribute: "data-filter" + }, icon: { type: "datalist", options: [ "none", "alert", "arrow-d", "arrow-l", "arrow-r", @@ -88,6 +93,16 @@ var BCommonProperties = { options: [ "default", "a", "b", "c", "d", "e" ], defaultValue: "default", htmlAttribute: "data-track-theme" + }, + inset: { + type: "boolean", + defaultValue: true, + htmlAttribute: "data-inset", + // because data-inset="false" is the real default, do this: + forceAttribute: true + // FIXME: would be better to distinguish from the default that + // occurs if you leave it off, vs. the default we think + // the user is most likely to want } }; @@ -831,11 +846,10 @@ var BWidgetRegistry = { }, /** - * Represents a button. A "text" string property holds the button text. + * Represents a base button widget */ - Button: { + ButtonBase: { parent: "Base", - paletteImageName: "jqm_button.svg", editable: { selector: "span > .ui-btn-text", propertyName: "text" @@ -878,6 +892,18 @@ var BWidgetRegistry = { defaultValue: "slide", htmlAttribute: "data-transition" }, + }, + template: '%TEXT%' + }, + + /** + * Represents a button. A "text" string property holds the button text. + */ + + Button: { + parent: "ButtonBase", + paletteImageName: "jqm_button.svg", + properties: { icon: BCommonProperties.icon, iconpos: $.extend({}, BCommonProperties.iconpos, { invalidIn: "Navbar" @@ -1550,34 +1576,10 @@ var BWidgetRegistry = { /** * Represents a unordered list element. */ - List: { - parent: "Base", + SimpleList: { + parent: "ListBase", paletteImageName: "jqm_list.svg", - dragHeader: true, properties: { - inset: { - type: "boolean", - defaultValue: true, - htmlAttribute: "data-inset", - // because data-inset="false" is the real default, do this: - forceAttribute: true - // FIXME: would be better to distinguish from the default that - // occurs if you leave it off, vs. the default we think - // the user is most likely to want - }, - theme: BCommonProperties.theme, - divider: { - displayName: "divider theme", - type: "string", - options: [ "default", "a", "b", "c", "d", "e" ], - defaultValue: "default", - htmlAttribute: "data-divider-theme" - }, - filter: { - type: "boolean", - defaultValue: false, - htmlAttribute: "data-filter" - }, filter_theme: $.extend({}, BCommonProperties.theme, { displayName: "filter theme", htmlAttribute: "data-filter-theme" @@ -1590,11 +1592,81 @@ var BWidgetRegistry = { } }, template: '
    ', + }, + + /** + * Represents a unordered button list element. + */ + ButtonList: { + parent: "SimpleList", + paletteImageName: "jqm_button_list.svg", + zones: [ + { + allow: [ "ButtonListItem"] + } + ] + }, + + /** + * Represents a unordered button list element. + */ + TextList: { + parent: "SimpleList", + paletteImageName: "jqm_text_list.svg", + zones: [ + { + allow: [ "TextListItem" ] + } + ] + }, + + /** + * Represents a icon list element. + */ + IconList: { + parent: "SimpleList", + paletteImageName: "jqm_icon_list.svg", + template: '
      ', + zones: [ + { + allow: [ "IconListItem" ] + } + ] + }, + + /** + * Represents a Thumbnail list element. + */ + ThumbnailList: { + parent: "SimpleList", + paletteImageName: "jqm_thumbnail_list.svg", + template: '
        ', + zones: [ + { + allow: [ "ThumbnailListItem" ] + } + ] + }, + /** + * Represents a base List widget + */ + ListBase: { + parent: "Base", + dragHeader: true, + properties: { + inset: BCommonProperties.inset, + filter: BCommonProperties.filter, + theme: BCommonProperties.theme, + divider_theme: $.extend({}, BCommonProperties.theme, { + displayName: "divider theme", + htmlAttribute: "data-divider-theme" + }) + }, zones: [ { name: "default", cardinality: "N", - allow: [ "ListItem", "ListDivider", "ListButton" ] + allow: [ "SimpleListItem", "ListDivider" ] } ], delegate: function (domNode, admNode) { @@ -1612,6 +1684,16 @@ var BWidgetRegistry = { ); // Reconstruct the domNode. return filterForm.wrap(newNode).parent().append(domNode); + }, + init: function (node) { + // initial state is three button ListItem + var i; + for (i = 0; i < 3; i++) { + var listType = node.getType(), itemName = "SimpleListItem"; + if (listType !== "OrderedList") + itemName = listType + "Item"; + node.addChild(ADM.createNode(itemName)); + } } }, @@ -1619,19 +1701,92 @@ var BWidgetRegistry = { * Represents an ordered list element. */ OrderedList: { - parent: "List", + parent: "ListBase", paletteImageName: "jqm_ordered_list.svg", - template: '
          ' + template: '
            ', + }, + + /** + * Represents a Split list element. + */ + ThumbnailSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_thumbnail_split_list.svg", + zones: [ + { + name: "default", + cardinality: "N", + allow: [ "ThumbnailSplitListItem"] + } + ], + }, + + /** + * Represents a Split list element. + */ + SimpleSplitList: { + parent: "ListBase", + paletteImageName: "jqm_simple_split_list.svg", + properties: { + theme: { + type: "string", + options: [ "default", "a", "b", "c", "d", "e" ], + defaultValue: "default", + htmlAttribute: "data-split-theme" + }, + split_icon: { + displayName: "split icon", + type: "string", + options: [ "none", "alert", "arrow-d", "arrow-l", "arrow-r", + "arrow-u", "back", "check", "delete", "forward", + "gear", "grid", "home", "info", "minus", "plus", + "refresh", "search", "star" ], + defaultValue: "none", + htmlAttribute: "data-split-icon" + } + }, + template: '
              ', + zones: [ + { + allow: [ "SimpleSplitListItem"] + } + ] + }, + + /** + * Represents a Split list element. + */ + TextSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_text_split_list.svg", + zones: [ + { + allow: [ "TextSplitListItem"] + } + ] + }, + + /** + * Represents a Split list element. + */ + IconSplitList: { + parent: "SimpleSplitList", + paletteImageName: "jqm_icon_split_list.svg", + zones: [ + { + allow: [ "IconSplitListItem"] + } + ] }, /** * Represents a list item element. */ - ListItem: { + SimpleListItem: { parent: "Base", - displayLabel: "List Item", + displayLabel: "Simple List Item", paletteImageName: "jqm_list_item.svg", - allowIn: [ "List", "OrderedList" ], + allowIn: [ "SimpleList", "OrderedList" ], editable: { selector: "", propertyName: "text" @@ -1639,7 +1794,7 @@ var BWidgetRegistry = { properties: { text: { type: "string", - defaultValue: "List Item" + defaultValue: "", }, theme: BCommonProperties.theme, filtertext: { @@ -1652,24 +1807,207 @@ var BWidgetRegistry = { template: '
            • %TEXT%
            • ' }, + /** + * Represents a list button item element. + */ + ButtonListItem: { + parent: "SimpleListItem", + displayLabel: "Button List Item", + paletteImageName: "jqm_button_list_item.svg", + allowIn: [ "ButtonList" ], + zones: [ + { + name: "default", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a list text item element. + */ + TextListItem: { + parent: "ButtonListItem", + displayLabel: "Text List Item", + paletteImageName: "jqm_text_list_item.svg", + allowIn: [ "TextList" ], + template: '
            • ', + zones: [ + { + allow: [ "TextButton" ] + }, + ], + init: function (node) { + // initial state is three TextButton + node.addChild(ADM.createNode("TextButton")); + } + }, + + /** + * Represents a IconListItem element. + */ + IconListItem: { + parent: "ButtonListItem", + displayLabel: "Icon List Item", + paletteImageName: "jqm_icon_list_item.svg", + allowIn: [ "IconList" ], + template: '
            • ', + zones: [ + { + allow: [ "IconButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("IconButton")); + } + }, + + /** + * Represents a ThumbnailListItem element. + */ + ThumbnailListItem: { + parent: "ButtonListItem", + displayLabel: "Thumbnail List Item", + paletteImageName: "jqm_thumbnail_list_item.svg", + allowIn: [ "ThumbnailList"], + template: '
            • ', + zones: [ + { + allow: [ "ThumbnailButton" ] + } + ], + init: function (node) { + // initial state is a ThumbnailButton + node.addChild(ADM.createNode("ThumbnailButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + ThumbnailSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Thumbnail Split List Item", + paletteImageName: "jqm_thumbnail_split_list_item.svg", + allowIn: [ "ThumbnailSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "ThumbnailButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("ThumbnailButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + SimpleSplitListItem: { + parent: "ButtonListItem", + displayLabel: "Simple Split List Item", + paletteImageName: "jqm_simple_split_list_item.svg", + allowIn: [ "SimpleSplitList" ], + properties: { + text: { + defaultValue: "List Item", + }, + }, + template: '
            • ', + zones: [ + { + name: "left", + cardinality: "2", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("ListButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + IconSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Icon Split List Item", + paletteImageName: "jqm_icon_split_list_item.svg", + allowIn: [ "IconSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "IconButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("IconButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + + /** + * Represents a SplitListItem element. + */ + TextSplitListItem: { + parent: "SimpleSplitListItem", + displayLabel: "Text Split List Item", + paletteImageName: "jqm_text_split_list_item.svg", + allowIn: [ "TextSplitList" ], + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "TextButton" ] + }, + { + name: "right", + cardinality: "1", + allow: [ "ListButton" ] + } + ], + init: function (node) { + // initial state is three buttons + node.addChild(ADM.createNode("TextButton")); + node.addChild(ADM.createNode("ListButton")); + } + }, + /** * Represents a list divider element. */ ListDivider: { - parent: "Base", + parent: "SimpleListItem", displayLabel: "List Divider", paletteImageName: "jqm_list_divider.svg", - allowIn: [ "List", "OrderedList" ], - editable: { - selector: "", - propertyName: "text" - }, + allowIn: [ "SimpleList", "OrderedList", "ButtonList", "TextList", "IconList", "ThumbnailList" ], properties: { text: { - type: "string", defaultValue: "List Divider" }, - theme: BCommonProperties.theme }, template: '
            • %TEXT%
            • ' }, @@ -1678,24 +2016,13 @@ var BWidgetRegistry = { * Represents a button. A "text" string property holds the button text. */ ListButton: { - parent: "Base", + parent: "ButtonBase", displayLabel: "List Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "List", "OrderedList" ], - editable: { - selector: "a", - propertyName: "text" - }, + allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "SimpleSplitListItem", "TextSplitListItem", "IconSplitListItem" ], properties: { text: { - type: "string", - defaultValue: "Button" - }, - target: { - type: "string", - defaultValue: "", - htmlAttribute: "href", - htmlSelector: "a" + defaultValue: "List Button" }, icon: $.extend({}, BCommonProperties.icon, { options: BCommonProperties.icon.options.slice(1), @@ -1709,8 +2036,7 @@ var BWidgetRegistry = { } }, template: function (node) { - var prop, countBubble, code = $('
            • %TEXT%
            • '); - var anchor = code.find('a'); + var prop, countBubble, code = $('%TEXT%<'); prop = node.getProperty("countbubble"); // Add the count bubble if countbubble property is not blank @@ -1718,12 +2044,135 @@ var BWidgetRegistry = { countBubble = $('') .attr('class', 'ui-li-count') .html(prop); - anchor.append(countBubble); + code.append(countBubble); }; return code; } - + }, + + /** + * Represents a button. A Icon_Image property holds the button text. + */ + IconButton: { + parent: "ButtonBase", + displayLabel: "Icon list Button", + paletteImageName: "jqm_icon_list_button.svg", + allowIn: [ "IconListItem", "IconSplitListItem" ], + properties: { + text: { + defaultValue: "Icon List Item" + }, + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" + } + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('%TEXT%<'); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('src', prop) + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.append(iconsrc); + }; + return code; + } + }, + + /** + * Represents a button. A Image property holds the button text. + */ + ThumbnailButton: { + parent: "ButtonBase", + displayLabel: "Thumbnail list Button", + paletteImageName: "jqm_thumbnail_list_button.svg", + allowIn: [ "ThumbnailSplitListItem", "ThumbnailListItem" ], + properties: { + text: { + type: "string", + defaultValue: "ThumbnailSplit List Item" + }, + }, + template:'', + zones: [ + { + name: "left", + cardinality: "1", + allow: [ "Image" ] + }, + { + name: "right", + cardinality: "N", + allow: [ "Text" ] + } + ], + init: function (node) { + // initial state is three Image and Texts + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); + } + }, + + /** + * Represents a button. A Image property holds the button text. + */ + TextButton: { + parent: "ButtonBase", + displayLabel: "Text list Button", + paletteImageName: "jqm_text_list_button.svg", + allowIn: [ "TextListItem", "TextSplitListItem" ], + properties: { + text: { + type: "string", + defaultValue: "Text List Item" + }, + }, + template:'', + zones: [ + { + name: "right", + cardinality: "N", + allow: [ "Text" ] + } + ], + init: function (node) { + // initial state is three Image and Texts + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + } }, /** From bdbcf2b9fce3c5afd02f710836f2265b0bf7d33b Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 11:55:53 +0800 Subject: [PATCH 03/35] [Widgets] Allow subtype to be treated as base type in type list checking --- src/js/widgets.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index b0c7b2d7..b1819eaa 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -3375,15 +3375,23 @@ var BWidget = { // returns: true, if type is the list string, or type is one of the // strings in list // false, otherwise, or if list is invalid - var i; + var i, parentType = type, + isType = function (srcType, targetType) { + if (srcType === targetType) + return true; + while (srcType && (srcType = BWidgetRegistry[srcType].parent)) { + if (srcType === targetType) + return true; + } + return false; + }; if (list) { - if (type === list) { + if (isType(type, list)) { return true; } else if (list.length > 0) { for (i = list.length - 1; i >= 0; i--) { - if (type === list[i]) { + if (isType(type, list[i])) return true; - } } } } From 0df704b682e862253883722f1221355b61d79dde Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 12:19:43 +0800 Subject: [PATCH 04/35] [ADM] Support child type morphing We can define a "morph" function for a zone so that When adding a child, it can be morphed to another type. With this feature, we can have a generic widget in the palette which can adapt to different types of containers when dropped on them. --- src/js/adm.js | 33 +++++++++++++++++++++++++++++++-- src/js/widgets.js | 7 ++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 99b1f1bf..39632f58 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1452,6 +1452,18 @@ ADMNode.prototype.hasUserVisibleDescendants = function () { return false; }; +/** + * Change this node to another type + * + * @param {String} type The type this node will morph to. + * @return {ADMNode} The morphed node. + */ +ADMNode.prototype.morphTo = function (type) { + var morphedChild = ADM.createNode(type); + this._inheritance = morphedChild._inheritance; + this._zones = morphedChild._zones; + return this; +}; /** * Adds given child object to this object, generally at the end of the first * zone that accepts the child. @@ -1519,11 +1531,19 @@ ADMNode.prototype.addChild = function (child, dryrun) { ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, dryrun) { // requires: assumes cardinality is "N", or a numeric string - var add = false, myType, childType, zone, cardinality, limit; + var add = false, myType, childType, zone, cardinality, limit, morph, + morphedChildType, morphedChild; myType = this.getType(); childType = child.getType(); zone = this._zones[zoneName]; + morph = BWidget.getZone(myType, zoneName).morph; + if (morph) { + morphedChildType = morph(childType, myType); + if (morphedChildType !== childType) { + childType = morphedChildType; + } + } if (!BWidget.zoneAllowsChild(myType, zoneName, childType)) { if (!dryrun) { console.warn("Warning: zone " + zoneName + @@ -1630,7 +1650,8 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, } } - var zone = this._zones[zoneName]; + var zone = this._zones[zoneName], + myType, childType, morph, morphedChildType; if (!zone) { console.error("Error: zone not found in insertChildInZone: " + zoneName); @@ -1642,6 +1663,14 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, } if (child instanceof ADMNode) { if (!dryrun) { + myType = this.getType(); + childType = child.getType(); + morph = BWidget.getZone(myType, zoneName).morph; + if (morph) { + morphedChildType = morph(childType, myType); + if (morphedChildType != childType) + child.morphTo(morphedChildType); + } zone.splice(index, 0, child); setRootRecursive(child, this._root); diff --git a/src/js/widgets.js b/src/js/widgets.js index b1819eaa..8a37b15f 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -159,6 +159,8 @@ var BCommonProperties = { * of this zone. * 6) itemWrapper: an HTML tag used to wrapp a child node before appending * to the zone + * 7) morph: function used to change the child type to another type before + * adding it to the zone * * The "properties" of each widget definition is an object, each property of * which names a property of the widget. These are objects with the following @@ -3440,7 +3442,7 @@ var BWidget = { * found. */ zoneAllowsChild: function (parentType, zone, childType) { - var parent, child, zones, i, allow, deny; + var parent, child, zones, i, allow, deny, morph; parent = BWidgetRegistry[parentType]; child = BWidgetRegistry[childType]; if ((typeof parent !== "object") || (typeof child !== "object")) { @@ -3451,6 +3453,9 @@ var BWidget = { if (zones && zones.length > 0) { for (i = zones.length - 1; i >= 0; i--) { if (zones[i].name === zone) { + morph = BWidget.getZone(parentType, zone).morph; + if (morph) + childType = morph(childType, parentType); allow = zones[i].allow; if (allow) { return BWidget.isTypeInList(childType, allow); From a0d86c3538b948179cb5cf164d0fbb880151d49c Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 1 Aug 2012 21:27:37 +0800 Subject: [PATCH 05/35] [ADM] Add max and min limit of cardinality --- src/js/adm.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/js/adm.js b/src/js/adm.js index 39632f58..4d4c498f 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1566,6 +1566,7 @@ ADMNode.prototype.addChildToZone = function (child, zoneName, zoneIndex, return false; } + cardinality = cardinality.max || cardinality; if (cardinality !== "N") { limit = parseInt(cardinality, 10); if (zone.length >= limit) { @@ -1786,12 +1787,30 @@ ADMNode.prototype.removeChild = function (child, dryrun) { * @return {ADMNode} The removed child, or null if not found. */ ADMNode.prototype.removeChildFromZone = function (zoneName, index, dryrun) { - var zone, removed, child, parentNode, parent; + var zone, removed, child, parent, cardinality, min; zone = this._zones[zoneName]; if (!zone) { console.error("Error: no such zone found while removing child: " + zoneName); } + cardinality = BWidget.getZoneCardinality(this.getType(), zoneName); + if (!cardinality) { + console.warn("Warning: no cardinality found for zone " + zoneName); + return false; + } + + if (cardinality.min) { + min = parseInt(cardinality.min, 10); + + if (zone.length <= min) { + alert("At least " + + cardinality.min + " " + + BWidget.getDisplayLabel(zone[index].getType()) + + (min === 1 ? " " : "s ") + + (min === 1 ? "is": "are") + " required and cannot be deleted!"); + return false; + } + } if (dryrun) { removed = [zone[index]]; From 5d7a0058b2e544087669447c3045fc17f92d9196 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 3 Aug 2012 14:58:30 +0800 Subject: [PATCH 06/35] [Widgets] Extend zones more gracefully Looking for parent zone with the same name. If found, extend it with descendant zone, otherwize add a new zone. --- index.html | 2 +- src/js/widgets.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 63575124..be1f29a0 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + @@ -35,7 +36,6 @@ - diff --git a/src/js/widgets.js b/src/js/widgets.js index 8a37b15f..1f3c4dff 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -2615,7 +2615,7 @@ var BWidget = { init: function () { // effects: add the type and displayLabel properties to widget // registry objects - var type, parentName; + var type, parentName, newZones, descendantZone, descendantZoneIndex; for (type in BWidgetRegistry) { if (BWidgetRegistry.hasOwnProperty(type)) { BWidgetRegistry[type].type = type; @@ -2653,6 +2653,26 @@ var BWidget = { } parentName = BWidgetRegistry[type].parent; while (parentName) { + if (BWidgetRegistry[parentName].zones) { + newZones = []; + $.each(BWidgetRegistry[parentName].zones, function (i, pZone) { + descendantZone = null; + if (BWidgetRegistry[type].zones) + $.each(BWidgetRegistry[type].zones, function (i, zone) { + if (pZone.name === zone.name) { + descendantZone = zone; + descendantZoneIndex = i; + return false; + } + }); + if (descendantZone) + BWidgetRegistry[type].zones[descendantZoneIndex] = $.extend(true, true, {}, pZone, descendantZone); + else + newZones.push(pZone); + }); + if(BWidgetRegistry[type].zones) + $.merge(BWidgetRegistry[type].zones, newZones); + } BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]); parentName = BWidgetRegistry[parentName].parent; } From f4af4bfd8d130a453bebd347af0922e995686676 Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 6 Aug 2012 15:35:28 +0800 Subject: [PATCH 07/35] [Widgets] Enable using function as a zone's "allow" field --- src/js/widgets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 1f3c4dff..fc85931b 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -150,7 +150,8 @@ var BCommonProperties = { * Each zone description in the array should be an object with: * 1) name identifying the zone point * 2) cardinality, either "1" or "N" representing number of contained items - * 3) allow: string or array of string names of allowable widgets + * 3) allow: string or array of string names or a function that returns + * a string or an array of allowable widgets * (all others will be denied) * 4) deny: string or array of string names of disallowed widgets * (all others will be allowed) @@ -3478,6 +3479,8 @@ var BWidget = { childType = morph(childType, parentType); allow = zones[i].allow; if (allow) { + if (typeof allow === "function") + allow = allow(parentType); return BWidget.isTypeInList(childType, allow); } deny = zones[i].deny; From f74ce2c944cf224d9cc2b3038ee8d723e08c4660 Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Tue, 31 Jul 2012 16:01:02 +0800 Subject: [PATCH 08/35] [Widgets] Implement list widgets using generic item and button --- src/assets/groups.json | 28 +++---- src/css/images/widgets/jqm_list_item.svg | 2 +- src/js/widgets.js | 93 +++++++++--------------- 3 files changed, 49 insertions(+), 74 deletions(-) diff --git a/src/assets/groups.json b/src/assets/groups.json index 90c81f47..507a5032 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -24,20 +24,22 @@ "List Views": [ { "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], "Unordered Lists": [ { - "Single Lists": [ { - "Simple Single List": ["SimpleList", "SimpleListItem", "ListDivider"], - "Button Single List": ["ButtonList", "ButtonListItem", "ListButton", "ListDivider"], - "Text Single List": ["TextList", "TextListItem", "ListDivider", "TextButton"], - "Icon Single List": ["IconList", "IconListItem", "IconButton", "ListDivider"], - "Thumbnail Single List": ["ThumbnailList", "ThumbnailListItem", "ThumbnailButton", "ListDivider"] - } + "Single Lists": [ + "SimpleList", + "ButtonList", + "TextList", + "IconList", + "ThumbnailList", + "SimpleListItem", + "ListDivider" ], - "Split Lists": [ { - "Simple Split List": ["SimpleSplitList", "SimpleSplitListItem"], - "Text Split List": ["TextSplitList", "TextSplitListItem", "TextButton"], - "Icon Split List": ["IconSplitList", "IconSplitListItem", "IconButton"], - "Thumbnail Split List": ["ThumbnailSplitList", "ThumbnailSplitListItem", "ThumbnailButton"] - } + "Split Lists": [ + "SimpleSplitList", + "TextSplitList", + "IconSplitList", + "ThumbnailSplitList", + "SimpleListItem", + "ListDivider" ] } ] diff --git a/src/css/images/widgets/jqm_list_item.svg b/src/css/images/widgets/jqm_list_item.svg index 00d56daa..7703f1a0 100644 --- a/src/css/images/widgets/jqm_list_item.svg +++ b/src/css/images/widgets/jqm_list_item.svg @@ -24,5 +24,5 @@ -Simple List Item +List Item diff --git a/src/js/widgets.js b/src/js/widgets.js index fc85931b..6405c260 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1603,11 +1603,6 @@ var BWidgetRegistry = { ButtonList: { parent: "SimpleList", paletteImageName: "jqm_button_list.svg", - zones: [ - { - allow: [ "ButtonListItem"] - } - ] }, /** @@ -1616,11 +1611,6 @@ var BWidgetRegistry = { TextList: { parent: "SimpleList", paletteImageName: "jqm_text_list.svg", - zones: [ - { - allow: [ "TextListItem" ] - } - ] }, /** @@ -1630,11 +1620,6 @@ var BWidgetRegistry = { parent: "SimpleList", paletteImageName: "jqm_icon_list.svg", template: '
                ', - zones: [ - { - allow: [ "IconListItem" ] - } - ] }, /** @@ -1644,11 +1629,6 @@ var BWidgetRegistry = { parent: "SimpleList", paletteImageName: "jqm_thumbnail_list.svg", template: '
                  ', - zones: [ - { - allow: [ "ThumbnailListItem" ] - } - ] }, /** * Represents a base List widget @@ -1665,11 +1645,28 @@ var BWidgetRegistry = { htmlAttribute: "data-divider-theme" }) }, + getItemType: function (listType) { + if (listType !== "OrderedList") + return listType + "Item"; + else + return "SimpleListItem"; + }, zones: [ { name: "default", cardinality: "N", - allow: [ "SimpleListItem", "ListDivider" ] + morph: function (childType, thisType) { + if (childType === "SimpleListItem") { + if (thisType === "OrderedList") + return "SimpleListItem"; + else + return thisType + "Item"; + } + return childType; + }, + allow: function (type) { + return [ BWidgetRegistry.ListBase.getItemType(type), "ListDivider" ]; + } } ], delegate: function (domNode, admNode) { @@ -1715,13 +1712,6 @@ var BWidgetRegistry = { ThumbnailSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_thumbnail_split_list.svg", - zones: [ - { - name: "default", - cardinality: "N", - allow: [ "ThumbnailSplitListItem"] - } - ], }, /** @@ -1749,11 +1739,6 @@ var BWidgetRegistry = { } }, template: '
                    ', - zones: [ - { - allow: [ "SimpleSplitListItem"] - } - ] }, /** @@ -1762,11 +1747,6 @@ var BWidgetRegistry = { TextSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_text_split_list.svg", - zones: [ - { - allow: [ "TextSplitListItem"] - } - ] }, /** @@ -1775,21 +1755,16 @@ var BWidgetRegistry = { IconSplitList: { parent: "SimpleSplitList", paletteImageName: "jqm_icon_split_list.svg", - zones: [ - { - allow: [ "IconSplitListItem"] - } - ] }, /** - * Represents a list item element. + * Represents a generic list item element. */ SimpleListItem: { parent: "Base", - displayLabel: "Simple List Item", + displayLabel: "List Item", paletteImageName: "jqm_list_item.svg", - allowIn: [ "SimpleList", "OrderedList" ], + allowIn: [ "ListBase" ], editable: { selector: "", propertyName: "text" @@ -1821,7 +1796,7 @@ var BWidgetRegistry = { zones: [ { name: "default", - cardinality: "1", + cardinality: { min: "1", max: "1"}, allow: [ "ListButton" ] } ], @@ -1841,6 +1816,7 @@ var BWidgetRegistry = { template: '
                  • ', zones: [ { + name: "default", allow: [ "TextButton" ] }, ], @@ -1861,6 +1837,7 @@ var BWidgetRegistry = { template: '
                  • ', zones: [ { + name: "default", allow: [ "IconButton" ] } ], @@ -1881,6 +1858,7 @@ var BWidgetRegistry = { template: '
                  • ', zones: [ { + name: "default", allow: [ "ThumbnailButton" ] } ], @@ -1901,14 +1879,8 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "ThumbnailButton" ] }, - { - name: "right", - cardinality: "1", - allow: [ "ListButton" ] - } ], init: function (node) { // initial state is three buttons @@ -1921,7 +1893,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SimpleSplitListItem: { - parent: "ButtonListItem", + parent: "SimpleListItem", displayLabel: "Simple Split List Item", paletteImageName: "jqm_simple_split_list_item.svg", allowIn: [ "SimpleSplitList" ], @@ -1934,7 +1906,12 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "2", + cardinality: {min: "1", max: "1"}, + allow: [ "ListButton" ] + }, + { + name: "right", + cardinality: {min: "1", max: "1"}, allow: [ "ListButton" ] } ], @@ -1956,12 +1933,10 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "IconButton" ] }, { name: "right", - cardinality: "1", allow: [ "ListButton" ] } ], @@ -1983,12 +1958,10 @@ var BWidgetRegistry = { zones: [ { name: "left", - cardinality: "1", allow: [ "TextButton" ] }, { name: "right", - cardinality: "1", allow: [ "ListButton" ] } ], @@ -2006,7 +1979,7 @@ var BWidgetRegistry = { parent: "SimpleListItem", displayLabel: "List Divider", paletteImageName: "jqm_list_divider.svg", - allowIn: [ "SimpleList", "OrderedList", "ButtonList", "TextList", "IconList", "ThumbnailList" ], + allowIn: [ "ListBase" ], properties: { text: { defaultValue: "List Divider" From 8930b88d9254a8957c176176ec5eb2be2112d2b6 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 11:50:37 +0800 Subject: [PATCH 09/35] [Widgets] Implement ordered list as a property of ListBase --- src/assets/groups.json | 4 ---- src/js/widgets.js | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/assets/groups.json b/src/assets/groups.json index 507a5032..c29fd3e0 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -22,8 +22,6 @@ } ], "List Views": [ { - "Ordered List": ["OrderedList", "SimpleListItem", "ListDivider"], - "Unordered Lists": [ { "Single Lists": [ "SimpleList", "ButtonList", @@ -41,8 +39,6 @@ "SimpleListItem", "ListDivider" ] - } - ] } ], "Image": ["Image"] diff --git a/src/js/widgets.js b/src/js/widgets.js index 6405c260..022dab83 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1594,7 +1594,6 @@ var BWidgetRegistry = { htmlAttribute: "data-filter-placeholder" } }, - template: '
                      ', }, /** @@ -1619,7 +1618,6 @@ var BWidgetRegistry = { IconList: { parent: "SimpleList", paletteImageName: "jqm_icon_list.svg", - template: '
                        ', }, /** @@ -1628,7 +1626,6 @@ var BWidgetRegistry = { ThumbnailList: { parent: "SimpleList", paletteImageName: "jqm_thumbnail_list.svg", - template: '
                          ', }, /** * Represents a base List widget @@ -1640,6 +1637,10 @@ var BWidgetRegistry = { inset: BCommonProperties.inset, filter: BCommonProperties.filter, theme: BCommonProperties.theme, + ordered: { + type: "boolean", + defaultValue: false, + }, divider_theme: $.extend({}, BCommonProperties.theme, { displayName: "divider theme", htmlAttribute: "data-divider-theme" @@ -1685,6 +1686,12 @@ var BWidgetRegistry = { // Reconstruct the domNode. return filterForm.wrap(newNode).parent().append(domNode); }, + template: function (node) { + if (node.getProperty("ordered")) + return $('
                            '); + else + return $('
                              '); + }, init: function (node) { // initial state is three button ListItem var i; @@ -1697,15 +1704,6 @@ var BWidgetRegistry = { } }, - /** - * Represents an ordered list element. - */ - OrderedList: { - parent: "ListBase", - paletteImageName: "jqm_ordered_list.svg", - template: '
                                ', - }, - /** * Represents a Split list element. */ @@ -1738,7 +1736,6 @@ var BWidgetRegistry = { htmlAttribute: "data-split-icon" } }, - template: '
                                  ', }, /** From 70ec2f24915f303e8d3f717f722d106d4b3b25cc Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 14:21:49 +0800 Subject: [PATCH 10/35] [Widgets] Change name of SimpleSplitList to ButtonSplitList --- src/assets/groups.json | 2 +- ...lit_list.svg => jqm_button_split_list.svg} | Bin 4042 -> 4042 bytes ...tem.svg => jqm_button_split_list_item.svg} | Bin 2464 -> 2464 bytes src/js/widgets.js | 28 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) rename src/css/images/widgets/{jqm_simple_split_list.svg => jqm_button_split_list.svg} (96%) rename src/css/images/widgets/{jqm_simple_split_list_item.svg => jqm_button_split_list_item.svg} (95%) diff --git a/src/assets/groups.json b/src/assets/groups.json index c29fd3e0..202514fa 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -32,7 +32,7 @@ "ListDivider" ], "Split Lists": [ - "SimpleSplitList", + "ButtonSplitList", "TextSplitList", "IconSplitList", "ThumbnailSplitList", diff --git a/src/css/images/widgets/jqm_simple_split_list.svg b/src/css/images/widgets/jqm_button_split_list.svg similarity index 96% rename from src/css/images/widgets/jqm_simple_split_list.svg rename to src/css/images/widgets/jqm_button_split_list.svg index 1542ca00d31cb6be251f3c765a1f62d6c6855d92..edd6c5ce5c304a8413ebdcacbe164acfd88ff113 100644 GIT binary patch delta 40 mcmX>le@cFX2M>1=Ln%WE5au)FO%CQ!=XOHyH@EV*G6MkWg9@qu delta 40 ncmX>le@cFX2M>2KLncEmLjgk$L+a#U9(C?u1b=fYk1I0(=${IP diff --git a/src/css/images/widgets/jqm_simple_split_list_item.svg b/src/css/images/widgets/jqm_button_split_list_item.svg similarity index 95% rename from src/css/images/widgets/jqm_simple_split_list_item.svg rename to src/css/images/widgets/jqm_button_split_list_item.svg index d3304a98acc6cbe53ff90d56e320bbcc28977284..1a0b781c3df3d82607c47374831d25c468a794d1 100644 GIT binary patch delta 39 kcmZ1=yg+z^5+`>OLn%WE5au)FP1fZ!hXL6bY0LL^5rT_o{ delta 39 lcmZ1=yg+z^5+`>tLncEmLjgk$L+WH*PDAcsBz`8RIRM3U34#Cs diff --git a/src/js/widgets.js b/src/js/widgets.js index 022dab83..a13bcc47 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1708,16 +1708,16 @@ var BWidgetRegistry = { * Represents a Split list element. */ ThumbnailSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_thumbnail_split_list.svg", }, /** * Represents a Split list element. */ - SimpleSplitList: { + ButtonSplitList: { parent: "ListBase", - paletteImageName: "jqm_simple_split_list.svg", + paletteImageName: "jqm_button_split_list.svg", properties: { theme: { type: "string", @@ -1742,7 +1742,7 @@ var BWidgetRegistry = { * Represents a Split list element. */ TextSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_text_split_list.svg", }, @@ -1750,7 +1750,7 @@ var BWidgetRegistry = { * Represents a Split list element. */ IconSplitList: { - parent: "SimpleSplitList", + parent: "ButtonSplitList", paletteImageName: "jqm_icon_split_list.svg", }, @@ -1869,7 +1869,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ThumbnailSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Thumbnail Split List Item", paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], @@ -1889,11 +1889,11 @@ var BWidgetRegistry = { /** * Represents a SplitListItem element. */ - SimpleSplitListItem: { + ButtonSplitListItem: { parent: "SimpleListItem", - displayLabel: "Simple Split List Item", - paletteImageName: "jqm_simple_split_list_item.svg", - allowIn: [ "SimpleSplitList" ], + displayLabel: "Button Split List Item", + paletteImageName: "jqm_button_split_list_item.svg", + allowIn: [ "ButtonSplitList" ], properties: { text: { defaultValue: "List Item", @@ -1923,7 +1923,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ IconSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], @@ -1948,7 +1948,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "SimpleSplitListItem", + parent: "ButtonSplitListItem", displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], @@ -1990,9 +1990,9 @@ var BWidgetRegistry = { */ ListButton: { parent: "ButtonBase", - displayLabel: "List Button", + displayLabel: "Extra Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "SimpleSplitListItem", "TextSplitListItem", "IconSplitListItem" ], + allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "ButtonSplitListItem", "TextSplitListItem", "IconSplitListItem" ], properties: { text: { defaultValue: "List Button" From 1f53b3f3224ab1684afe3a3ee040b910b3116f75 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 16:57:23 +0800 Subject: [PATCH 11/35] [Widgets] Introduce default htmlSelector --- src/js/widgets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index a13bcc47..7163e047 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -3063,7 +3063,8 @@ var BWidget = { getPropertyHTMLSelector: function (widgetType, property) { var schema = BWidget.getPropertySchema(widgetType, property); if (schema) { - return schema.htmlSelector; + return schema.htmlSelector !== undefined ? schema.htmlSelector : + BWidget.getWidgetAttribute(widgetType, "defaultHtmlSelector"); } return schema; }, From e917506bf688395773fe4e1bb87d8fa084e09029 Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 16:59:50 +0800 Subject: [PATCH 12/35] [Widgets] Extract text property to BCommonProperties --- src/js/widgets.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/js/widgets.js b/src/js/widgets.js index 7163e047..1505a4e1 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -69,6 +69,10 @@ var BCommonProperties = { defaultValue: "default", htmlAttribute: "data-position" }, + text: { + type: "string", + defaultValue: "Button" + }, theme: { type: "string", options: function() { From 27086a33a1aac4f672f63d54ae43cdd251f00c5c Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 7 Aug 2012 14:28:28 +0800 Subject: [PATCH 13/35] [Widgets] Collapse split list button into SplitListItem --- src/js/widgets.js | 163 ++++++++++++++++++++++++++++++---------------- 1 file changed, 108 insertions(+), 55 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 1505a4e1..2d769bd3 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -857,21 +857,7 @@ var BWidgetRegistry = { */ ButtonBase: { parent: "Base", - editable: { - selector: "span > .ui-btn-text", - propertyName: "text" - }, properties: { - text: { - type: "string", - defaultValue: "Button" - }, - right: { - displayName: "align right", - validIn: "Header", - type: "boolean", - defaultValue: false - }, target: { type: "targetlist", defaultValue: "", @@ -910,7 +896,18 @@ var BWidgetRegistry = { Button: { parent: "ButtonBase", paletteImageName: "jqm_button.svg", + editable: { + selector: "span > .ui-btn-text", + propertyName: "text" + }, properties: { + text: BCommonProperties.text, + right: { + displayName: "align right", + validIn: "Header", + type: "boolean", + defaultValue: false + }, icon: BCommonProperties.icon, iconpos: $.extend({}, BCommonProperties.iconpos, { invalidIn: "Navbar" @@ -1873,19 +1870,37 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ThumbnailSplitListItem: { - parent: "ButtonSplitListItem", + parent: "SplitListItemBase", displayLabel: "Thumbnail Split List Item", paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], zones: [ { name: "left", - allow: [ "ThumbnailButton" ] + cardinality: "1", + locator: "a", + allow: [ "Image" ] }, + { + name: "right", + cardinality: "N", + locator: "a", + allow: [ "Text" ] + } ], init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("ThumbnailButton")); + // initial state is three Image and Texts + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); + node.addChild(ADM.createNode("ListButton")); } }, @@ -1893,36 +1908,46 @@ var BWidgetRegistry = { /** * Represents a SplitListItem element. */ - ButtonSplitListItem: { - parent: "SimpleListItem", - displayLabel: "Button Split List Item", - paletteImageName: "jqm_button_split_list_item.svg", - allowIn: [ "ButtonSplitList" ], + SplitListItemBase: { + parent: "ButtonBase", + defaultHtmlSelector: "a", properties: { - text: { - defaultValue: "List Item", - }, + theme: $.extend(true, {}, BCommonProperties.theme, { + htmlSelector: "" + }) }, - template: '
                                • ', + template: '
                                • ', zones: [ { - name: "left", + name: "extra", cardinality: {min: "1", max: "1"}, allow: [ "ListButton" ] }, - { - name: "right", - cardinality: {min: "1", max: "1"}, - allow: [ "ListButton" ] - } ], init: function (node) { // initial state is three buttons node.addChild(ADM.createNode("ListButton")); - node.addChild(ADM.createNode("ListButton")); } }, + /** + * Represents a SplitListItem element. + */ + ButtonSplitListItem: { + parent: "SplitListItemBase", + displayLabel: "Button Split List Item", + paletteImageName: "jqm_button_split_list_item.svg", + allowIn: [ "ButtonSplitList" ], + template: '
                                • %TEXT%
                                • ', + editable: { + selector: ".ui-btn-text > a", + propertyName: "text" + }, + properties: { + text: BCommonProperties.text, + }, + }, + /** * Represents a SplitListItem element. */ @@ -1931,20 +1956,42 @@ var BWidgetRegistry = { displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], - zones: [ - { - name: "left", - allow: [ "IconButton" ] + properties: { + text: { + defaultValue: "Icon List Item" }, - { - name: "right", - allow: [ "ListButton" ] + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + htmlSelector: "img", + htmlAttribute: "src", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" } - ], - init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("IconButton")); - node.addChild(ADM.createNode("ListButton")); + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                • %TEXT%
                                • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.find('a').append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.find('a').append(iconsrc); + }; + return code; } }, @@ -1952,23 +1999,29 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "ButtonSplitListItem", + parent: "SplitListItemBase", displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], zones: [ { - name: "left", - allow: [ "TextButton" ] - }, - { - name: "right", - allow: [ "ListButton" ] + name: "default", + cardinality: "N", + locator: "a", + allow: [ "Text" ] } ], init: function (node) { // initial state is three buttons - node.addChild(ADM.createNode("TextButton")); + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); node.addChild(ADM.createNode("ListButton")); } }, @@ -1996,7 +2049,7 @@ var BWidgetRegistry = { parent: "ButtonBase", displayLabel: "Extra Button", paletteImageName: "jqm_list_button.svg", - allowIn: [ "ButtonListItem", "ThumbnailSplitListItem", "ButtonSplitListItem", "TextSplitListItem", "IconSplitListItem" ], + allowIn: [ "SplitListItemBase"], properties: { text: { defaultValue: "List Button" From 500be54e952d8d8ddfb38c754187f4bc8700931f Mon Sep 17 00:00:00 2001 From: yongfeng wu Date: Wed, 8 Aug 2012 14:26:36 +0800 Subject: [PATCH 14/35] [Widgets] Collapse list button into ListItem --- src/js/widgets.js | 158 ++++++++++++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 60 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 2d769bd3..36b39f63 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1770,7 +1770,7 @@ var BWidgetRegistry = { properties: { text: { type: "string", - defaultValue: "", + defaultValue: "List Item", }, theme: BCommonProperties.theme, filtertext: { @@ -1783,44 +1783,68 @@ var BWidgetRegistry = { template: '
                                • %TEXT%
                                • ' }, + /** + * Represents a ListItem element. + */ + ListItemBase: { + parent: "ButtonBase", + defaultHtmlSelector: "a", + properties: { + theme: $.extend(true, {}, BCommonProperties.theme, { + htmlSelector: "" + }) + }, + template: '
                                • ' + }, + /** * Represents a list button item element. */ ButtonListItem: { - parent: "SimpleListItem", + parent: "ListItemBase", displayLabel: "Button List Item", paletteImageName: "jqm_button_list_item.svg", allowIn: [ "ButtonList" ], - zones: [ - { - name: "default", - cardinality: { min: "1", max: "1"}, - allow: [ "ListButton" ] + editable: { + selector: ".ui-btn-text > a", + propertyName: "text" + }, + properties: { + text: { + type: "string", + defaultValue: "Button List Item", } - ], - init: function (node) { - node.addChild(ADM.createNode("ListButton")); - } + }, + template: '
                                • %TEXT%
                                • ', }, /** * Represents a list text item element. */ TextListItem: { - parent: "ButtonListItem", + parent: "ListItemBase", displayLabel: "Text List Item", paletteImageName: "jqm_text_list_item.svg", allowIn: [ "TextList" ], - template: '
                                • ', zones: [ { name: "default", - allow: [ "TextButton" ] + cardinality: "N", + locator: "a", + allow: [ "Text" ] }, ], init: function (node) { // initial state is three TextButton - node.addChild(ADM.createNode("TextButton")); + var widgit; + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "h3"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); + widgit = ADM.createNode("Text"); + widgit.setProperty("type", "p"); + widgit.setProperty("text", "Text List Item"); + node.addChild(widgit); } }, @@ -1832,16 +1856,42 @@ var BWidgetRegistry = { displayLabel: "Icon List Item", paletteImageName: "jqm_icon_list_item.svg", allowIn: [ "IconList" ], - template: '
                                • ', - zones: [ - { - name: "default", - allow: [ "IconButton" ] + properties: { + text: { + defaultValue: "Icon List Item" + }, + iconsrc: { + type: "url-uploadable", + defaultValue: "src/css/images/widgets/tizen_image.svg", + htmlSelector: "img", + htmlAttribute: "src", + forceAttribute: true + }, + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "0" } - ], - init: function (node) { - // initial state is three buttons - node.addChild(ADM.createNode("IconButton")); + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                • %TEXT%
                                • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.find('a').append(countBubble); + }; + prop = node.getProperty("iconsrc"); + // Add the count bubble if iconsrc property is not blank + if (prop.trim() != '') { + iconsrc = $('') + .attr('width','16') + .attr('class', 'ui-li-icon'); + code.find('a').append(iconsrc); + }; + return code; } }, @@ -1849,20 +1899,36 @@ var BWidgetRegistry = { * Represents a ThumbnailListItem element. */ ThumbnailListItem: { - parent: "ButtonListItem", + parent: "ListItemBase", displayLabel: "Thumbnail List Item", paletteImageName: "jqm_thumbnail_list_item.svg", allowIn: [ "ThumbnailList"], - template: '
                                • ', zones: [ { - name: "default", - allow: [ "ThumbnailButton" ] + name: "left", + cardinality: "1", + locator: "a", + allow: [ "Image" ] + }, + { + name: "right", + cardinality: "N", + locator: "a", + allow: [ "Text" ] } ], init: function (node) { // initial state is a ThumbnailButton - node.addChild(ADM.createNode("ThumbnailButton")); + var image = ADM.createNode("Image"); + var text = ADM.createNode("Text"); + text.setProperty("type", "h3"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + text = ADM.createNode("Text"); + text.setProperty("type", "p"); + text.setProperty("text", "Thumbnail List Item"); + node.addChild(text); + node.addChild(image); } }, @@ -1909,14 +1975,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SplitListItemBase: { - parent: "ButtonBase", - defaultHtmlSelector: "a", - properties: { - theme: $.extend(true, {}, BCommonProperties.theme, { - htmlSelector: "" - }) - }, - template: '
                                • ', + parent: "ListItemBase", zones: [ { name: "extra", @@ -1940,7 +1999,7 @@ var BWidgetRegistry = { allowIn: [ "ButtonSplitList" ], template: '
                                • %TEXT%
                                • ', editable: { - selector: ".ui-btn-text > a", + selector: "", propertyName: "text" }, properties: { @@ -2051,34 +2110,13 @@ var BWidgetRegistry = { paletteImageName: "jqm_list_button.svg", allowIn: [ "SplitListItemBase"], properties: { - text: { - defaultValue: "List Button" - }, icon: $.extend({}, BCommonProperties.icon, { options: BCommonProperties.icon.options.slice(1), defaultValue: "arrow-r" }), theme: BCommonProperties.theme, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "" - } }, - template: function (node) { - var prop, countBubble, code = $('%TEXT%<'); - - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.append(countBubble); - }; - - return code; - } + template: '', }, /** From 9dfc8e6e6d26660689ab7d9cca0398dc348f9317 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 8 Aug 2012 16:20:23 +0800 Subject: [PATCH 15/35] [Widgets] Introduce multiple inheritance --- src/js/adm.js | 14 ++------------ src/js/widgets.js | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 4d4c498f..6b4de9f4 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -1008,18 +1008,8 @@ function ADMNode(widgetType) { var currentType = widgetType, widget, zones, length, i, func; this._valid = false; - this._inheritance = []; - - while (currentType) { - widget = BWidgetRegistry[currentType]; - if (typeof widget === "object") { - this._inheritance.push(currentType); - currentType = widget.parent; - } else { - console.error("Error: invalid type hierarchy creating ADM node"); - return; - } - } + this._inheritance = [widgetType]; + $.merge(this._inheritance, BWidget.getAncestors(widgetType)); this._uid = ++ADMNode.prototype._lastUid; diff --git a/src/js/widgets.js b/src/js/widgets.js index 36b39f63..3e10f122 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -2681,7 +2681,7 @@ var BWidget = { init: function () { // effects: add the type and displayLabel properties to widget // registry objects - var type, parentName, newZones, descendantZone, descendantZoneIndex; + var type, newZones, descendantZone, descendantZoneIndex; for (type in BWidgetRegistry) { if (BWidgetRegistry.hasOwnProperty(type)) { BWidgetRegistry[type].type = type; @@ -2717,8 +2717,7 @@ var BWidget = { if (type === "OptionHeader") { BWidgetRegistry[type].displayLabel = "Option Header"; } - parentName = BWidgetRegistry[type].parent; - while (parentName) { + $.each(BWidget.getAncestors(type), function (i, parentName) { if (BWidgetRegistry[parentName].zones) { newZones = []; $.each(BWidgetRegistry[parentName].zones, function (i, pZone) { @@ -2740,8 +2739,7 @@ var BWidget = { $.merge(BWidgetRegistry[type].zones, newZones); } BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]); - parentName = BWidgetRegistry[parentName].parent; - } + }); } } }, @@ -3458,6 +3456,20 @@ var BWidget = { zoneName); }, + // helper function + getAncestors: function (type) { + var ancestors = [], + parents = BWidgetRegistry[type].parent; + if (!parents) + return []; + if ( typeof parents === "string") + parents = [parents]; + ancestors = $.merge(ancestors, parents); + $.each(parents, function (i, parentName) { + $.merge(ancestors, BWidget.getAncestors(parentName)); + }) + return ancestors; + }, // helper function isTypeInList: function (type, list) { // requires: list can be an array, a string, or invalid @@ -3468,11 +3480,7 @@ var BWidget = { isType = function (srcType, targetType) { if (srcType === targetType) return true; - while (srcType && (srcType = BWidgetRegistry[srcType].parent)) { - if (srcType === targetType) - return true; - } - return false; + return BWidget.getAncestors(srcType).indexOf(targetType) !== -1; }; if (list) { if (isType(type, list)) { From d260e624012ccab95668744ccbf020b6f9aaadf5 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 8 Aug 2012 16:22:12 +0800 Subject: [PATCH 16/35] [Widgets] Use multiple inheritance to implement split list widgets --- src/js/widgets.js | 198 ++-------------------------------------------- 1 file changed, 5 insertions(+), 193 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 3e10f122..76a52b01 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1835,7 +1835,6 @@ var BWidgetRegistry = { }, ], init: function (node) { - // initial state is three TextButton var widgit; widgit = ADM.createNode("Text"); widgit.setProperty("type", "h3"); @@ -1918,7 +1917,6 @@ var BWidgetRegistry = { } ], init: function (node) { - // initial state is a ThumbnailButton var image = ADM.createNode("Image"); var text = ADM.createNode("Text"); text.setProperty("type", "h3"); @@ -1993,95 +1991,33 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ ButtonSplitListItem: { - parent: "SplitListItemBase", + parent: [ "ButtonListItem", "SplitListItemBase" ], displayLabel: "Button Split List Item", paletteImageName: "jqm_button_split_list_item.svg", allowIn: [ "ButtonSplitList" ], - template: '
                                • %TEXT%
                                • ', - editable: { - selector: "", - propertyName: "text" - }, - properties: { - text: BCommonProperties.text, - }, }, /** * Represents a SplitListItem element. */ IconSplitListItem: { - parent: "ButtonSplitListItem", + parent: [ "IconListItem", "ButtonSplitListItem" ], displayLabel: "Icon Split List Item", paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], - properties: { - text: { - defaultValue: "Icon List Item" - }, - iconsrc: { - type: "url-uploadable", - defaultValue: "src/css/images/widgets/tizen_image.svg", - htmlSelector: "img", - htmlAttribute: "src", - forceAttribute: true - }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } - }, - template: function(node) { - var prop, iconsrc, countBubble, code = $('
                                • %TEXT%
                                • '); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.find('a').append(countBubble); - }; - prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank - if (prop.trim() != '') { - iconsrc = $('') - .attr('width','16') - .attr('class', 'ui-li-icon'); - code.find('a').append(iconsrc); - }; - return code; - } }, /** * Represents a SplitListItem element. */ TextSplitListItem: { - parent: "SplitListItemBase", + parent: [ "TextListItem", "SplitListItemBase" ], displayLabel: "Text Split List Item", paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], - zones: [ - { - name: "default", - cardinality: "N", - locator: "a", - allow: [ "Text" ] - } - ], init: function (node) { - // initial state is three buttons - var widgit; - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "h3"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "p"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - node.addChild(ADM.createNode("ListButton")); + BWidgetRegistry.TextListItem.init(node); + BWidgetRegistry.SplitListItemBase.init(node); } }, @@ -2119,130 +2055,6 @@ var BWidgetRegistry = { template: '', }, - /** - * Represents a button. A Icon_Image property holds the button text. - */ - IconButton: { - parent: "ButtonBase", - displayLabel: "Icon list Button", - paletteImageName: "jqm_icon_list_button.svg", - allowIn: [ "IconListItem", "IconSplitListItem" ], - properties: { - text: { - defaultValue: "Icon List Item" - }, - iconsrc: { - type: "url-uploadable", - defaultValue: "src/css/images/widgets/tizen_image.svg", - forceAttribute: true - }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } - }, - template: function(node) { - var prop, iconsrc, countBubble, code = $('%TEXT%<'); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.append(countBubble); - }; - prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank - if (prop.trim() != '') { - iconsrc = $('') - .attr('src', prop) - .attr('width','16') - .attr('class', 'ui-li-icon'); - code.append(iconsrc); - }; - return code; - } - }, - - /** - * Represents a button. A Image property holds the button text. - */ - ThumbnailButton: { - parent: "ButtonBase", - displayLabel: "Thumbnail list Button", - paletteImageName: "jqm_thumbnail_list_button.svg", - allowIn: [ "ThumbnailSplitListItem", "ThumbnailListItem" ], - properties: { - text: { - type: "string", - defaultValue: "ThumbnailSplit List Item" - }, - }, - template:'', - zones: [ - { - name: "left", - cardinality: "1", - allow: [ "Image" ] - }, - { - name: "right", - cardinality: "N", - allow: [ "Text" ] - } - ], - init: function (node) { - // initial state is three Image and Texts - var image = ADM.createNode("Image"); - var text = ADM.createNode("Text"); - text.setProperty("type", "h3"); - text.setProperty("text", "Thumbnail List Item"); - node.addChild(text); - text = ADM.createNode("Text"); - text.setProperty("type", "p"); - text.setProperty("text", "Thumbnail List Item"); - node.addChild(text); - node.addChild(image); - } - }, - - /** - * Represents a button. A Image property holds the button text. - */ - TextButton: { - parent: "ButtonBase", - displayLabel: "Text list Button", - paletteImageName: "jqm_text_list_button.svg", - allowIn: [ "TextListItem", "TextSplitListItem" ], - properties: { - text: { - type: "string", - defaultValue: "Text List Item" - }, - }, - template:'', - zones: [ - { - name: "right", - cardinality: "N", - allow: [ "Text" ] - } - ], - init: function (node) { - // initial state is three Image and Texts - var widgit; - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "h3"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - widgit = ADM.createNode("Text"); - widgit.setProperty("type", "p"); - widgit.setProperty("text", "Text List Item"); - node.addChild(widgit); - } - }, - /** * Represents a div element. */ From 2ec8ee03001aebd747b02f68e714ed5f9a02a967 Mon Sep 17 00:00:00 2001 From: John Chen Date: Thu, 9 Aug 2012 11:38:29 +0800 Subject: [PATCH 17/35] [Widgets] Remove unused svg files and display labels --- .../images/widgets/jqm_button_list_item.svg | 28 ------------------ .../widgets/jqm_button_split_list_item.svg | Bin 2464 -> 0 bytes src/css/images/widgets/jqm_icon_list_item.svg | Bin 2444 -> 0 bytes .../widgets/jqm_icon_split_list_item.svg | Bin 2468 -> 0 bytes src/css/images/widgets/jqm_text_list_item.svg | 28 ------------------ .../widgets/jqm_text_split_list_item.svg | Bin 2458 -> 0 bytes .../widgets/jqm_thumbnail_list_item.svg | 24 --------------- .../widgets/jqm_thumbnail_split_list_item.svg | 24 --------------- src/js/widgets.js | 18 ----------- 9 files changed, 122 deletions(-) delete mode 100644 src/css/images/widgets/jqm_button_list_item.svg delete mode 100644 src/css/images/widgets/jqm_button_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_icon_list_item.svg delete mode 100644 src/css/images/widgets/jqm_icon_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_text_list_item.svg delete mode 100644 src/css/images/widgets/jqm_text_split_list_item.svg delete mode 100644 src/css/images/widgets/jqm_thumbnail_list_item.svg delete mode 100644 src/css/images/widgets/jqm_thumbnail_split_list_item.svg diff --git a/src/css/images/widgets/jqm_button_list_item.svg b/src/css/images/widgets/jqm_button_list_item.svg deleted file mode 100644 index 097e1803..00000000 --- a/src/css/images/widgets/jqm_button_list_item.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - -Button List Item - diff --git a/src/css/images/widgets/jqm_button_split_list_item.svg b/src/css/images/widgets/jqm_button_split_list_item.svg deleted file mode 100644 index 1a0b781c3df3d82607c47374831d25c468a794d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2464 zcma);YflqF6o%ignD`%7_<$zTvaMpN^@ey$R7?9)+alQ?;r`k4%=)M*d%vwBvkGNh zAM}E!?dO5=OmBl9v)aSzKu4;F^Y8L1@vHKGi2u8szu>tE&mP{kuwEW%ET3zPmdYc~ z@^HS5-fgU;IFi@X^O6UDI!HKEud#O)^4CO{GZwSj!-DBo@w!5;y^>dxTIy)*hV1WO zS!1r{u*wD5sMS6#lA&Sn^(<&idslIW2)<*@IoS);Tou*MCH9E5L#`c{byW+rQz&hu zSE$Euq&dTy>uDWX;7+L8)E05I!NL|fY-t~@eI!r7S$=Tu2TH7ShCdB<1L|i##;1{TL!UwCs-A$&C%ij5rWDs>^topSM6omS zA=A&Pyh(0S;((lW@t}_0HR5o;t)t2KS>UZrk9I;vyJY45KQ$i{aVuy#;jOEinx{8P z;41zn%kGQIZEX>eZIy`1eLk;Sm)QL^;msF)Ddeyb&^(!2pH0@FLCs^{XQ+ki*1~3n zRcECe>N%(9g=O?i!>7-uVRIInsjtiD)+X)7?rM|u{%C@D+PM<;C3Sk7O|L+NJG~kD z$B5k|ro_F0Ob4mh`zJh&!u4}}u0h`jr}lS<9{11^tE9U@|nlw`?Q#j+< zGJJR7TcqO?)@SJBi0wmc8+nK1)Yxz1U7P{-V2pmBd1w9ws$dLws@63}#N##2=l^X) z->+ulIX2R-Xv3KKSAC|TC(fRnY2z53UUEXC&$leRT+LZVsIxoiV>0h)n0AE95&-l4BJjFb9`b;q+ z>>y;OPmc_lPC0yzEzWk|63gr=tP-BwMR$$a6YEx-vT0^o_ QQVws<)Oa?mV!J_f6tIxZ8mbRoQ z*_@u;nc2C%GpB!kH}qHo9jc>DXKJaZ6SZ}ut{!Syxk_5#ox$m<34I4{S9^hbs=jtL zkJKVEkM&45bwdr^(y~_dT<`TsYkI-$6LjzKUeku2>5W$4X55)qne|as&fYC^XBp1A zKIj#1+s^~%h28}}rnQgNzK&H7^zZU2@l^Re!v8(!uXt}EvyZn;td|Ro=7ux%27Birf1BuX#$r~xSTO%OURTJqSMq9HOC61!ko|*e zYs|G2R(a%Z)M}p=$j~78dLA^Uv#U5o1mCgdoa_f~u8L|GH};9OO|Bi6byY`rXK-5F zenve8h2{)vuBUZmK{}yoOWVZN0t?&Zu&D#I_PBWp&SGx6L0i-?NlVOholGAG4Xt4F z7%eSm#6;Q=lV(a~f@GvE zA$J$K1v)-qeTqJg*gnFxk#|H+jr|th#Tj4^hUhoVC(F-M1!KTdwXPW=9N5#FarWd)8^;)DoO3gdtJEVi#W!MD*|{Kl8D$H)ALy4+7HgDH z=Dd3vd3ui9n<-{;oXqwnPPw<#&R>8#@Xx~THI%!2376!Zd6}YAj#MpBt3kGc6<5B7 zbd7J3rK8Lbd`&(%hpEr5?y^Ph-VaZ0Li`b(mt*(zAGOm5Ujt&#c-$GDVxBrZrkD|S z7&6nNM+Qu%9684pXS=@=OPngK5}w>cca7N->oz)N)6BHS*=tO)*-JY7Pv-}o`o8}G z*h1>^ulk0Uo1EPPU3NyFF>IRSGq)f1{%W}6RtnjS3PjlqT9kF}Q&xs^DE`BU=f9l? BUa9~9 diff --git a/src/css/images/widgets/jqm_icon_split_list_item.svg b/src/css/images/widgets/jqm_icon_split_list_item.svg deleted file mode 100644 index c17666240ba5b10a1c34570057439798bceca8c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2468 zcma);YflqF6o%ignD`%7_<$tRvaMpN^^O-36%s^aj3H18R7$~8uxR}2>hsR*(3TV> zlXhq3+|PN>+5Pjop~o8NP#tADQ%gOasI4P)^-$BwRnh{_3`$o`?suSewHK(T>T6f? za4o{~SdVm5H`LHAEo)WJ^Ldb!Y8zR(ygl?%`E zaKD4z9jv4{lGl^-k_UgMK_WIs@IRaCo>*eBLDxprLERUM(7L1`iV zjCu?T%^B8QPwU76cS6;cwu!3+7PiS@QwM16A$bbUVs5)ZThuT~OU!hgOdkggtzh#Q zEiLYhX;*Mq*Bwr~P-2}k{AqCNQ$PDLyp5Dw`V2ak^%QJAW$)~mGP<6i&pp#8irvD8 zOg|^`Cb@BmLvq%^gF1RwiNpQ2jwa)0o?VL`ZHJ6@$jXC%YCa+2X3%uXuA|$Ur8i38 zD*h+S?u)B!Z4;4gm59oHKC8Ja?EV__=8L|J!g)r#y|q^$UEiLf;6t_IH3D_s}A%qeP&H#HbM8EHRGXFePFa|tT>zX0r;Tq=i|2CrU z*R$~w8|gP{!Lb^Bdp}^s}&g&COljgiG?yv`mpJhpQHDtAV$I6<59n zca3+Exg*aHd`&(%hpEr5?y^N>?}uM)Li`b(mt*(zAGOm5Ujt&#__;GY#XNO-Ofe(u zFl44jj|`YjIed;S&UU{gmN->dB|N!@?i#Zv)@^jkrkQDtv)7npvzK)EOXmlkTHap( zwvf8~tG?moCTI6Rm!01(Mqr=4pT@K4j@6v~u=g9p-M3Q6`CBH*WmG20WzeIXYm%}x LoKNw~BcA^P0)t~= diff --git a/src/css/images/widgets/jqm_text_list_item.svg b/src/css/images/widgets/jqm_text_list_item.svg deleted file mode 100644 index 1cdb8675..00000000 --- a/src/css/images/widgets/jqm_text_list_item.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - -Text List Item - diff --git a/src/css/images/widgets/jqm_text_split_list_item.svg b/src/css/images/widgets/jqm_text_split_list_item.svg deleted file mode 100644 index 30788fadd0c37e034412b28c3750c87a108b6f58..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2458 zcma);TTc^F6ouC-CjN&J9?(Qurd2Gp-VrrXF+nuOm6pepf{nj~iXiJKc zlXhnI{j&C+`SZJ>M;dBhU1d5^TYVj=qXYHyK(oqK(jwOkPERf9+i-i@4cuc5w4(*2 zmXLX*hq|t7YUqYmw5DfzuTOfX=V%{cdzb4wZRn|9>lNG#oduOSA64bqcPr?uz**M^ zz2Iv9dEh+P+YraB_V7B;q3VHtDxVU+D*p$>zYF~Z*G**hh_;3Ia$&K2ZZUc)7m?+G zzKz{&yreu*)YI#dhj=<@xKgk2cNXf`#Fi@-tJ=eZ`B#a$LalvLRFhWfSnP)Cf4j29 zT+88<$8@7r$FxX=h9TCoU@<+ri!)?!iZ|C}FK}~JR6Ez$Bi9bKc3!qs9pjzAX`}s= zehdrC8Q$Da+sJ}+Le-|W$g2$&wy0rC->}+8^BA1P+V+CAXknU_Sm`>IJ`5Jx!RH}X z+R%(?cW~6#ZJu`E#6D-l)8J`9{~X7N8aX%g8Fa4b3D|tXy{lu+_<4*y&&+@ z{hTVB^d>d-sacl@>eyW)56{~=mW-bT?%K>~CsedcRqp@O@(~%gf~8~by1J=(W}^hI z;(zk&xwzcd78%)BiL5;5^SX73-(M5ae9@P&8a4u&Cu?ikWDgqjJl1`NUbt^9d}erc zRl1>{b6OocM$a^Snm!Giv-nJNT|W0V={HVSo2vJV4dQL*PB@k{>2Wu`0ui3{W|$u% zc9Wcv^aeT|wBqa^b2SRr&+)kieVf>vd2N=!}KDU~Ubk+zK7 z9po07_=NQt<~U;e0N+O50W~%D+e8<4fFl^8-!wm2et|9+1Kz52&5`lwjOzJ+A2If; z`B=qA`i=WAX8zTmY3PZ&CuiF@$GGEMn@L=y8JR2I5u?uD3bGebwy1l7ei3D{M+s%F zySI_I=cK>6VkgJV>}cYadqeO12DlCXB;37(a)&qJvV3P=rYMyoRSVQ=kgedwov$HX z<6UIwDD#6@Q%tU5nzPHNYzf_a;a8iIe?;fS+`awB{S3g@klZtVo(yj>Z=F6{%m~{L zmFY7hL$*_noO6r2-EWCyo+_LYk=(_0jolObHoj%k&a}n(D{Qj)3pV_v^MgpO?=Jv* zNK^h*--)tG{4tXz85{-#4xk!|#&eUaC8DJ7{RZ*$y)X3qEtB*zzI&pyJCQ7pwo?4w Hh|hlkF6&|4 diff --git a/src/css/images/widgets/jqm_thumbnail_list_item.svg b/src/css/images/widgets/jqm_thumbnail_list_item.svg deleted file mode 100644 index 659e8a8b..00000000 --- a/src/css/images/widgets/jqm_thumbnail_list_item.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - -Thumbnail List Item - diff --git a/src/css/images/widgets/jqm_thumbnail_split_list_item.svg b/src/css/images/widgets/jqm_thumbnail_split_list_item.svg deleted file mode 100644 index bd03745a..00000000 --- a/src/css/images/widgets/jqm_thumbnail_split_list_item.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - -Thumbnail Split List Item - diff --git a/src/js/widgets.js b/src/js/widgets.js index 76a52b01..4378ba2a 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1802,8 +1802,6 @@ var BWidgetRegistry = { */ ButtonListItem: { parent: "ListItemBase", - displayLabel: "Button List Item", - paletteImageName: "jqm_button_list_item.svg", allowIn: [ "ButtonList" ], editable: { selector: ".ui-btn-text > a", @@ -1823,8 +1821,6 @@ var BWidgetRegistry = { */ TextListItem: { parent: "ListItemBase", - displayLabel: "Text List Item", - paletteImageName: "jqm_text_list_item.svg", allowIn: [ "TextList" ], zones: [ { @@ -1852,8 +1848,6 @@ var BWidgetRegistry = { */ IconListItem: { parent: "ButtonListItem", - displayLabel: "Icon List Item", - paletteImageName: "jqm_icon_list_item.svg", allowIn: [ "IconList" ], properties: { text: { @@ -1899,8 +1893,6 @@ var BWidgetRegistry = { */ ThumbnailListItem: { parent: "ListItemBase", - displayLabel: "Thumbnail List Item", - paletteImageName: "jqm_thumbnail_list_item.svg", allowIn: [ "ThumbnailList"], zones: [ { @@ -1935,8 +1927,6 @@ var BWidgetRegistry = { */ ThumbnailSplitListItem: { parent: "SplitListItemBase", - displayLabel: "Thumbnail Split List Item", - paletteImageName: "jqm_thumbnail_split_list_item.svg", allowIn: [ "ThumbnailSplitList" ], zones: [ { @@ -1992,8 +1982,6 @@ var BWidgetRegistry = { */ ButtonSplitListItem: { parent: [ "ButtonListItem", "SplitListItemBase" ], - displayLabel: "Button Split List Item", - paletteImageName: "jqm_button_split_list_item.svg", allowIn: [ "ButtonSplitList" ], }, @@ -2002,8 +1990,6 @@ var BWidgetRegistry = { */ IconSplitListItem: { parent: [ "IconListItem", "ButtonSplitListItem" ], - displayLabel: "Icon Split List Item", - paletteImageName: "jqm_icon_split_list_item.svg", allowIn: [ "IconSplitList" ], }, @@ -2012,8 +1998,6 @@ var BWidgetRegistry = { */ TextSplitListItem: { parent: [ "TextListItem", "SplitListItemBase" ], - displayLabel: "Text Split List Item", - paletteImageName: "jqm_text_split_list_item.svg", allowIn: [ "TextSplitList" ], init: function (node) { BWidgetRegistry.TextListItem.init(node); @@ -2042,8 +2026,6 @@ var BWidgetRegistry = { */ ListButton: { parent: "ButtonBase", - displayLabel: "Extra Button", - paletteImageName: "jqm_list_button.svg", allowIn: [ "SplitListItemBase"], properties: { icon: $.extend({}, BCommonProperties.icon, { From fd5849a45e2fc8f2ad0fabe9b9f8008a4c55393b Mon Sep 17 00:00:00 2001 From: John Chen Date: Tue, 21 Aug 2012 17:56:28 +0800 Subject: [PATCH 18/35] [Widgets] Enable count bubble on all list types Also set the default value of count bubble to empty, i.e, no count bubble --- src/js/widgets.js | 74 ++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index 4378ba2a..d748da53 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1755,11 +1755,37 @@ var BWidgetRegistry = { paletteImageName: "jqm_icon_split_list.svg", }, + /** + * Represents a base ListItem element. + */ + ListItemBase: { + parent: "Base", + properties: { + countbubble: { + type: "string", + displayName: "count bubble", + defaultValue: "" + } + }, + template: function(node) { + var prop, iconsrc, countBubble, code = $('
                                • '); + prop = node.getProperty("countbubble"); + // Add the count bubble if countbubble property is not blank + if (prop.trim() != '') { + countBubble = $('') + .attr('class', 'ui-li-count') + .html(prop); + code.append(countBubble); + }; + return code; + } + }, + /** * Represents a generic list item element. */ SimpleListItem: { - parent: "Base", + parent: "ListItemBase", displayLabel: "List Item", paletteImageName: "jqm_list_item.svg", allowIn: [ "ListBase" ], @@ -1780,28 +1806,33 @@ var BWidgetRegistry = { htmlAttribute: "data-filtertext" } }, - template: '
                                • %TEXT%
                                • ' + template: function (node) { + return BWidgetRegistry.ListItemBase.template(node).append(node.getProperty('text')); + }, }, /** - * Represents a ListItem element. + * Represents a Clickable ListItem element. */ - ListItemBase: { - parent: "ButtonBase", + ClickableListItem: { + parent: [ "ListItemBase", "ButtonBase" ], defaultHtmlSelector: "a", properties: { theme: $.extend(true, {}, BCommonProperties.theme, { htmlSelector: "" }) }, - template: '
                                • ' + template: function (node) { + var code = BWidgetRegistry.ListItemBase.template(node); + return code.append($('').append(code.find('span.ui-li-count'))); + }, }, /** * Represents a list button item element. */ ButtonListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "ButtonList" ], editable: { selector: ".ui-btn-text > a", @@ -1813,14 +1844,17 @@ var BWidgetRegistry = { defaultValue: "Button List Item", } }, - template: '
                                • %TEXT%
                                • ', + template: function (node) { + return BWidgetRegistry.ClickableListItem.template(node) + .find('a').append(node.getProperty('text')).end(); + }, }, /** * Represents a list text item element. */ TextListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "TextList" ], zones: [ { @@ -1860,24 +1894,12 @@ var BWidgetRegistry = { htmlAttribute: "src", forceAttribute: true }, - countbubble: { - type: "string", - displayName: "count bubble", - defaultValue: "0" - } }, template: function(node) { - var prop, iconsrc, countBubble, code = $('
                                • %TEXT%
                                • '); - prop = node.getProperty("countbubble"); - // Add the count bubble if countbubble property is not blank - if (prop.trim() != '') { - countBubble = $('') - .attr('class', 'ui-li-count') - .html(prop); - code.find('a').append(countBubble); - }; + var prop, iconsrc, + code = BWidgetRegistry.ButtonListItem.template(node); prop = node.getProperty("iconsrc"); - // Add the count bubble if iconsrc property is not blank + // Add the icon if iconsrc property is not blank if (prop.trim() != '') { iconsrc = $('') .attr('width','16') @@ -1892,7 +1914,7 @@ var BWidgetRegistry = { * Represents a ThumbnailListItem element. */ ThumbnailListItem: { - parent: "ListItemBase", + parent: "ClickableListItem", allowIn: [ "ThumbnailList"], zones: [ { @@ -1963,7 +1985,7 @@ var BWidgetRegistry = { * Represents a SplitListItem element. */ SplitListItemBase: { - parent: "ListItemBase", + parent: "ClickableListItem", zones: [ { name: "extra", From d3bb8831e27ecd6c6bbd417ccc23d1a8f9344fb7 Mon Sep 17 00:00:00 2001 From: Donna Wu Date: Tue, 21 Aug 2012 14:44:04 +0800 Subject: [PATCH 19/35] [FileIO] Support themes in root directory of sandbox when exporting --- src/js/serialize.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/js/serialize.js b/src/js/serialize.js index 533b1cab..555ec92f 100644 --- a/src/js/serialize.js +++ b/src/js/serialize.js @@ -425,11 +425,23 @@ $(function () { } function getDesignHeaders(design, useSandboxUrl) { - var i, props, el, designRoot, headers; + var i, props, el, designRoot, headers, toCorrectPath; designRoot = design || ADM.getDesignRoot(); headers = []; props = designRoot.getProperty('metas'); + toCorrectPath = function (header) { + var path = header.value; + // If need to use sandbox url + if (header.inSandbox) { + if (useSandboxUrl) { + path = toSandboxUrl(path); + } else { + path = path.replace(/^\//, ''); + } + } + return path; + }; for (i in props) { // Skip design only header properties if (props[i].hasOwnProperty('designOnly') && props[i].designOnly) { @@ -444,12 +456,7 @@ $(function () { if ((typeof props[i].value !== 'string') || (props[i].value.length <= 0)) { continue; } - // If need to use sandbox url - if (useSandboxUrl && props[i].inSandbox) { - el = el + '="' + toSandboxUrl(props[i].value) + '"'; - } else { - el = el + '="' + props[i].value + '"'; - } + el = el + '="' + toCorrectPath(props[i]) + '"'; if (props[i].hasOwnProperty('content')) { el = el + ' content="' + props[i].content + '"'; } @@ -470,11 +477,7 @@ $(function () { } el = ''; headers.push(el); } @@ -492,11 +495,7 @@ $(function () { } el = ''; headers.push(el); } From 03e9feba41ab0f5f5b97ae081350d12871823e81 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 22 Aug 2012 14:56:54 +0800 Subject: [PATCH 20/35] [Layout View] Revert css changes in 8ee0558e Sorting is still OK without this change and it causes bad appearance of ButtonGroup and ThumbnailSplitList --- src/css/composer.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/composer.css b/src/css/composer.css index 5663474c..40b1d136 100644 --- a/src/css/composer.css +++ b/src/css/composer.css @@ -48,7 +48,7 @@ /*************************/ /* Class specific tweaks */ /*************************/ -.nrc-sortable-container.ui-content .adm-node { +.nrc-sortable-container.ui-content > * { margin-top: 10px; margin-bottom: 10px; } From 499e82265fa586f48d35c879e4867bdbba4b6604 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 24 Aug 2012 14:25:19 +0800 Subject: [PATCH 21/35] [ADM] Use moveNode to insert child if old parent is not null --- src/js/adm.js | 55 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 6b4de9f4..cf0c6f11 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -359,7 +359,7 @@ ADM.endTransaction = function () { * @return {ADMNode} The child object, on success; null, on failure. */ ADM.addChild = function (parentRef, childRef, dryrun) { - var parent, child; + var parent, child, oldParent, oldType, oldZone, oldZoneIndex; parent = ADM.toNode(parentRef); if (!parent) { @@ -379,6 +379,12 @@ ADM.addChild = function (parentRef, childRef, dryrun) { return null; } + oldParent = child.getParent(); + if (oldParent) { + oldType = child.getType(); + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (parent.addChild(child, dryrun)) { if (dryrun) { return true; @@ -388,7 +394,11 @@ ADM.addChild = function (parentRef, childRef, dryrun) { ADM.transaction({ type: "add", parent: child.getParent(), - child: child + child: child, + oldParent: oldParent, + oldType: oldType, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -475,7 +485,7 @@ ADM.addChildRecursive = function (parentRef, childRef, dryrun) { * @private */ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { - var sibling, child; + var sibling, child, oldParent, oldType, oldZone, oldZoneIndex; sibling = ADM.toNode(siblingRef); if (!sibling) { @@ -496,6 +506,12 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { childRef); } + oldParent = child.getParent(); + if (oldParent) { + oldType = child.getType(); + oldZone = child.getZone(); + oldZoneIndex = child.getZoneIndex(); + } if (sibling.insertChildRelative(child, offset, dryrun)) { if (dryrun) { return true; @@ -504,7 +520,11 @@ ADM.insertChildRelative = function (siblingRef, childRef, offset, dryrun) { type: "insertRelative", sibling: sibling, child: child, - offset: offset + offset: offset, + oldParent: oldParent, + oldType: oldType, + oldZone: oldZone, + oldZoneIndex: oldZoneIndex }); return child; } @@ -760,21 +780,21 @@ ADM.transaction = function (obj) { */ ADM.undo = function () { var obj, undo = function (obj) { - if (obj.type === "add") { + if ( ["add", "insertRelative", "move"].indexOf(obj.type) !== -1) { ADM.ensurePageInactive(obj.child); - obj.parent.removeChild(obj.child); + if (obj.oldParent) { + if (obj.oldType !== obj.child.getType()) + obj.child.morphTo(obj.oldType); + obj.child.moveNode(obj.oldParent, obj.oldZone, obj.oldZoneIndex); + ADM.setSelected(obj.child); + } + else + obj.child.getParent().removeChild(obj.child); } else if (obj.type === "remove") { obj.parent.insertChildInZone(obj.child, obj.zone, obj.zoneIndex); ADM.setSelected(obj.child); } - else if (obj.type === "move") { - obj.node.moveNode(obj.oldParent, obj.oldZone, obj.oldZoneIndex); - ADM.setSelected(obj.node); - } - else if (obj.type === "insertRelative") { - obj.sibling.getParent().removeChild(obj.child); - } else if (obj.type === "propertyChange") { // TODO: this could require deeper copy of complex properties obj.node.setProperty(obj.property, obj.oldValue, obj.data); @@ -1641,7 +1661,7 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, } } - var zone = this._zones[zoneName], + var zone = this._zones[zoneName], oldParent, myType, childType, morph, morphedChildType; if (!zone) { console.error("Error: zone not found in insertChildInZone: " + @@ -1653,6 +1673,13 @@ ADMNode.prototype.insertChildInZone = function (child, zoneName, index, return false; } if (child instanceof ADMNode) { + oldParent = child.getParent(); + if (oldParent) { + if (oldParent === this && child.getZone() === zoneName + && child.getZoneIndex() < index) + index --; + return child.moveNode(this, zoneName, index, dryrun); + } if (!dryrun) { myType = this.getType(); childType = child.getType(); From d4fede6abbf90f8ead02d69e68c7ebed9d21f41d Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 24 Aug 2012 14:29:10 +0800 Subject: [PATCH 22/35] [Layout View] Use a new algorithm for sorting Previous algorithm only supports one zone containers or Headers, and it works hard to determine the position for insertion. The new algorithm firstly tries to insert to the zone of the nearest sibling using enhenced insertChildAfter/Before, if fails, uses addChild to automatically find a zone to insert. --- src/js/composer.js | 152 ++++++++++----------------------------------- 1 file changed, 32 insertions(+), 120 deletions(-) diff --git a/src/js/composer.js b/src/js/composer.js index c1eb7178..cceaa880 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -279,58 +279,6 @@ $(function() { } }; - var addNewNodeOnDrop = function (domParent, domChildren, adm, pid, - nodeRef, role, domNode) { - var newNode, domSibling, sid, admChildren, domIndex, debug; - - debug = (window.top.$.rib && window.top.$.rib.debug()); - domIndex = domChildren.index(domNode); - - // Append first(only)/last child to this container - if (domIndex >= domChildren.length-1 || role === 'page') { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Appended node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Append child failed:',role); - } - } else if (domIndex > 0) { - // Insert nth child into this container - domSibling = $(domNode, domParent).prev('.adm-node'); - sid = domSibling.attr('data-uid'); - if (adm.insertChildAfter(sid, nodeRef, true)) { - newNode = adm.insertChildAfter(sid, nodeRef); - debug && console.log('Inserted nth node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert nth child failed:',role); - } - } else { - // Add 1st child into an empty container - if (domChildren.length-1 <= 0) { - if (adm.addChild(pid, nodeRef, true)) { - newNode = adm.addChild(pid, nodeRef); - debug && console.log('Added 1st node',role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Add 1st child failed:',role); - } - } else { - // Insert 1st child into non-empty container - admChildren = adm.toNode(pid).getChildren(); - sid = admChildren.length && admChildren[0].getUid(); - if (adm.insertChildBefore(sid, nodeRef, true)) { - newNode = adm.insertChildBefore(sid, nodeRef); - debug && console.log('Inserted 1st node', role); - newNode && adm.setSelected(newNode); - } else { - console.warn('Insert 1st child failed:', role); - } - } - } - }; - window.top.$.rib = window.top.$.rib || {}; window.top.$.rib.dndfilter = dndfilter; @@ -643,16 +591,14 @@ $(function() { }, stop: function(event, ui){ trackOffsets('stop: ',ui,$(this).data('sortable')); - var type, isDrop, + var isDrop, pid = $(this).attr('data-uid'), - node = null, adm = window.parent.ADM, - bw = window.parent.BWidget, root = adm.getDesignRoot(), - node, zones, newParent, newZone, - rdx, idx, cid, pid, sid, + nodeRef, newParent, newNode, + cid, pid, sibling, children, parent, - role, card; + role, prevItem = ui.item, nextItem = ui.item; role = $(this).attr('data-role') || ''; @@ -703,87 +649,53 @@ $(function() { ui.item.remove(); return false; } - - // Drop from palette: add a node if (isDrop) { if (ui.item.data('adm-node')) { - type = ui.item.data('adm-node').type; + nodeRef = ui.item.data('adm-node').type; } - if (!type) { + if (!nodeRef) { console.warn('Drop failed: Missing node type'); ui.item.remove(); return false; } - - children = $($(this).sortable('option', 'items'), this) - .add(ui.item); - addNewNodeOnDrop(this, children, adm, pid, type, - role, ui.item); - ui.item.remove(); - return; - - // Sorted from layoutView: move a node - } else { - children = ui.item.parent().children('.adm-node') - .add(ui.item); - idx = children.index(ui.item); + } + else { cid = ui.item.attr('data-uid'); // closest() will select current element if it matches // the selector, so we start with its parent. + nodeRef = cid && root.findNodeByUid(cid); + if (event && event.ctrlKey) { + nodeRef = adm.copySubtree(nodeRef); + } + } + + while (prevItem[0] || nextItem[0]) { + prevItem = prevItem.prev('.adm-node'); + if (prevItem[0] && (newNode = adm.insertChildAfter + (prevItem.attr('data-uid'), nodeRef))) + break; + nextItem = nextItem.next('.adm-node'); + if (nextItem[0] && (newNode = adm.insertChildBefore + (nextItem.attr('data-uid'), nodeRef))) + break; + } + if (!prevItem[0] && !nextItem[0]) { pid = ui.item.parent() .closest('.adm-node.ui-sortable,'+ '.orig-adm-node.ui-sortable') .attr('data-uid'); - node = cid && root.findNodeByUid(cid); - if (event && event.ctrlKey) { - node = adm.copySubtree(node); // Clone it - addNewNodeOnDrop(this, children, adm, pid, node, - role, ui.item); - } else { - newParent = pid && root.findNodeByUid(pid); - zones = newParent && bw.getZones(newParent.getType()); - card = newParent && zones && - bw.getZoneCardinality(newParent.getType(), - zones[0]); - - // Notify the ADM that element has been moved - if ((zones && zones.length===1 && card !== '1')) { - if (!node || - !adm.moveNode(node, newParent, zones[0], - idx)) { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } else { - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } - } else if (node && newParent && - newParent.getType() === 'Header') { - for (var z=0; z < zones.length; z++) { - if (adm.moveNode(node, newParent, zones[z], - 0, true)) { - newZone = zones[z]; - break; - } - } - if (newZone) { - adm.moveNode(node, newParent, newZone, 0); - debug && console.log('Move node worked'); - if (node) adm.setSelected(node.getUid()); - } else { - console.warn('Move node failed'); - ui.item.remove(); - return false; - } - } else { - console.warn('Move node failed: invalid zone'); + newParent = pid && root.findNodeByUid(pid); + if (!(newNode = adm.addChild(newParent, nodeRef))) { + if (isDrop) { ui.item.remove(); - return false; + return true; } + return false; } } + if (newNode) + adm.setSelected(newNode); } }) .bind('mousedown.composer', function(event) { From 5b7d9f8b7a45bc4052bf56bade38bf77222a2bcf Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 27 Aug 2012 12:52:09 +0800 Subject: [PATCH 23/35] [Layout View] Fix focus styling problem --- src/js/composer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/composer.js b/src/js/composer.js index cceaa880..e041ffff 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -333,7 +333,7 @@ $(function() { } }; $(e.target).subtree().add(document) - .unbind('click vmousedown vmousecancel vmouseup vmouseover focus' + .unbind('click vmousedown vmousecancel vmouseup vmouseover focus focusin' + ' vmouseout blur mousedown touchmove'); $(e.target).subtree('.adm-node:not(.delegation),.orig-adm-node').each( From 2141541b9b849e0add569f8969e91b479c271273 Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 27 Aug 2012 12:58:34 +0800 Subject: [PATCH 24/35] [Widgets] Change iconsrc property display name to Icon Source --- src/js/widgets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/widgets.js b/src/js/widgets.js index d748da53..3987c855 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -1768,7 +1768,7 @@ var BWidgetRegistry = { } }, template: function(node) { - var prop, iconsrc, countBubble, code = $('
                                • '); + var prop, countBubble, code = $('
                                • '); prop = node.getProperty("countbubble"); // Add the count bubble if countbubble property is not blank if (prop.trim() != '') { @@ -1888,6 +1888,7 @@ var BWidgetRegistry = { defaultValue: "Icon List Item" }, iconsrc: { + displayName: "icon source", type: "url-uploadable", defaultValue: "src/css/images/widgets/tizen_image.svg", htmlSelector: "img", From d91d22efd36f413ec5a8a49d4ad230b64e7c5fcd Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 29 Aug 2012 11:09:30 +0800 Subject: [PATCH 25/35] [Palette View] Rearrange widget positions --- src/assets/groups.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/assets/groups.json b/src/assets/groups.json index 202514fa..b8c6ed6e 100644 --- a/src/assets/groups.json +++ b/src/assets/groups.json @@ -21,27 +21,27 @@ "Boolean": ["#0._hidden_node.jqm_input_boolean"] } ], + "Image": ["Image"], "List Views": [ { "Single Lists": [ + "SimpleListItem", + "ListDivider", "SimpleList", "ButtonList", "TextList", "IconList", - "ThumbnailList", - "SimpleListItem", - "ListDivider" + "ThumbnailList" ], "Split Lists": [ + "SimpleListItem", + "ListDivider", "ButtonSplitList", "TextSplitList", "IconSplitList", - "ThumbnailSplitList", - "SimpleListItem", - "ListDivider" + "ThumbnailSplitList" ] } - ], - "Image": ["Image"] + ] } ], From d288bfbffa46831b4bfb1a8fea66fb6847faf5a5 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 09:52:14 +0800 Subject: [PATCH 26/35] [General] Don't treat url started with "src" to be in sandbox --- src/js/projects.js | 2 +- src/js/views/layout.js | 9 --------- src/js/widgets.js | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/js/projects.js b/src/js/projects.js index df82845f..7209ba88 100644 --- a/src/js/projects.js +++ b/src/js/projects.js @@ -27,7 +27,7 @@ $(function () { // Filter to find sandbox resources relativeFilter:{ type: "url-uploadable", - value: /^(?!(https?|ftp):\/+).+/i + value: /^(?!((https?|ftp):|src)\/+).+/i }, // Object to save refernce count for sandbox resource resourceRef: {}, diff --git a/src/js/views/layout.js b/src/js/views/layout.js index e925c36c..98fa2f0f 100644 --- a/src/js/views/layout.js +++ b/src/js/views/layout.js @@ -428,15 +428,6 @@ // these lines. $(domNode).removeAttr('disabled'); $(domNode).children().removeAttr('disabled'); - - // Set default src for empty image to make them show up - // TODO: This case may need to improve, such as we can show a box - // with "empty image" message to notice the user - if ((admNode.getType() === "Image") && (!admNode.getProperty('src'))) { - if ($(domNode).is('img')) { - $(domNode).attr('src', "src/css/images/widgets/tizen_image.svg"); - } - } } }); })(jQuery); diff --git a/src/js/widgets.js b/src/js/widgets.js index 3987c855..373f5db9 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -960,7 +960,7 @@ var BWidgetRegistry = { properties: { src: { type: "url-uploadable", - defaultValue: "", + defaultValue: "src/css/images/widgets/tizen_image.svg", htmlAttribute: "src", forceAttribute: true }, From 3b294d49c081074d293a80decf1989485b5c6d4d Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 10:00:58 +0800 Subject: [PATCH 27/35] [Property View] Fix bug: Can't bring up upload dialog In Google Chrome 15.0.874.121, the upload dialog can't show if we use the parent of the clicked item --- src/js/views/property.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/views/property.js b/src/js/views/property.js index 2f3eaa45..ba0deebe 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -225,7 +225,7 @@ textInput = optionsWrapper.prev('input'); saveDir = $.rib.pmUtils.ProjectDir + "/" + $.rib.pmUtils.getActive() + "/images/"; - $.rib.fsUtils.upload("image", $(this).parent(), function(file) { + $.rib.fsUtils.upload("image", null, function(file) { // Write uploaded file to sandbox $.rib.fsUtils.write(saveDir + file.name, file, function (newFile) { textInput.val("images/" + newFile.name).change(); From 20935975c9306aa3c4d7ff83bc767eb38640111f Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 11:03:52 +0800 Subject: [PATCH 28/35] [Live View] Update recently used list when deleting a device --- src/js/views/live.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/views/live.js b/src/js/views/live.js index 195657f7..97a35927 100644 --- a/src/js/views/live.js +++ b/src/js/views/live.js @@ -72,6 +72,7 @@ buttonSet.append($('').click(function () { var type = widget._projectDevice.type; delete widget._userDevices[widget._projectDevice.name]; + widget._findOptionByText(widget._recentDevices, widget._projectDevice.name).remove(); applyDeviceChange(deviceForm, type); })); deviceForm From 2531876b13769600d9882585214a67c5843c8c26 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 12:19:52 +0800 Subject: [PATCH 29/35] [Live View] Fix RIB-9: Not checking device size when rotating --- src/js/views/live.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/js/views/live.js b/src/js/views/live.js index 195657f7..582bf9fd 100644 --- a/src/js/views/live.js +++ b/src/js/views/live.js @@ -17,7 +17,9 @@ options: { iframe: null, - contentDocument: null + contentDocument: null, + maxDeviceSize: 10000, + minDeviceSize: 240, }, _create: function() { @@ -31,7 +33,9 @@ rotateDeviceButton, widget = this, screenCoordElement = function (name, min, className) { - return $('') + return $('') .attr("name", name) .addClass(className); }, @@ -273,6 +277,18 @@ .addClass("rotateDevice separated") .appendTo(deviceToolbar) .click( function () { + if (widget._screenWidth.val() < widget.options.minDeviceSize || + widget._screenHeight.val() < widget.options.minDeviceSize) { + alert("Device size should not be less than " + + widget.options.minDeviceSize); + return; + } + else if (widget._screenWidth.val() > widget.options.maxDeviceSize || + widget._screenHeight.val() > widget.options.maxDeviceSize) { + alert("Device size should not be greater than " + + widget.options.maxDeviceSize); + return; + } widget._projectDevice.rotating = !widget._projectDevice.rotating; widget._projectDevice.screenWidth = widget._screenHeight.val(); widget._projectDevice.screenHeight = widget._screenWidth.val(); From eaac1af52a629cdd30973199a2c039a28265d430 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 14:07:52 +0800 Subject: [PATCH 30/35] [Live View] Fix RIB-29 Height becomes floating number when adding device --- src/js/views/live.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/views/live.js b/src/js/views/live.js index 582bf9fd..16c600fb 100644 --- a/src/js/views/live.js +++ b/src/js/views/live.js @@ -473,9 +473,11 @@ var scaleW = screenWidth/deviceInfo.screen.width, scaleH = screenHeight/deviceInfo.screen.height; deviceInfo.screen.width *= scaleW; + deviceInfo.screen.width = Math.round(deviceInfo.screen.width); deviceInfo.screen.offset.left *= scaleW; deviceInfo.screen.offset.right *= scaleW; deviceInfo.screen.height *= scaleH; + deviceInfo.screen.height = Math.round(deviceInfo.screen.height); deviceInfo.screen.offset.top *= scaleH; deviceInfo.screen.offset.bottom *= scaleH; From e8f93f4c35761887d4d4cac675619dda9d1ab2b3 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 14:20:07 +0800 Subject: [PATCH 31/35] [Outline View] Fix RIB-31 Tab doesn't work to get in and out of outline view --- src/js/views/tree.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/views/tree.js b/src/js/views/tree.js index 23d5560c..72bb5916 100644 --- a/src/js/views/tree.js +++ b/src/js/views/tree.js @@ -72,7 +72,6 @@ $(items[focusing]).addClass("focused"); items[focusing].scrollIntoViewIfNeeded(); } - return false; }, _setOption: function(key, value) { From 50b120743e9792899310f6ab11c666a46bbf4536 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 15:30:13 +0800 Subject: [PATCH 32/35] [Live View] Fix RIB-24 long device name displaying problem --- src/css/builder.css | 6 +++++- src/js/views/live.js | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/css/builder.css b/src/css/builder.css index 6ee74f20..46c22b70 100644 --- a/src/css/builder.css +++ b/src/css/builder.css @@ -340,7 +340,7 @@ body.ui-tabs.ui-widget { position: relative; display: inline-block; zoom: 1; - width: 102px; + width: 115px; z-index: 999; } .view.live .deviceSelect > a { @@ -418,6 +418,10 @@ body.ui-tabs.ui-widget { left: 120px; top: 0px; } +#deviceSelectMenu li ul li { + overflow: hidden; + text-overflow: ellipsis +} .view.live .deviceSelect .arrow b { display: block; } diff --git a/src/js/views/live.js b/src/js/views/live.js index 195657f7..a014b2b6 100644 --- a/src/js/views/live.js +++ b/src/js/views/live.js @@ -168,7 +168,8 @@ .append("") .appendTo(devicePanel); - widget._recentDevices = $('') + .appendTo(deviceToolbar) .append('') .change(function() { $("option:selected", this).each(function () { @@ -423,7 +424,7 @@ $('
                                • ').append( key ) .attr('id', key) .append( - $('>').addClass('fr') + $('').addClass('fr') ) .append( $('
                                    ') From 372b988617a3390cfaf85ec514001964263634fe Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 15:38:11 +0800 Subject: [PATCH 33/35] [Code View] Fix RIB-5: No code selected when switching to code view --- src/js/views/code.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/views/code.js b/src/js/views/code.js index ce22af5a..bef6497d 100644 --- a/src/js/views/code.js +++ b/src/js/views/code.js @@ -47,6 +47,8 @@ selected = activePage.getUid(); } } + if (selected) + widget._selectCode(widget._htmlDoc.doc, selected); }, refresh: function(event, widget) { From 5512373a685e5765fea7ca68b0144ba4e473cd6c Mon Sep 17 00:00:00 2001 From: Xuqing Kuang Date: Fri, 31 Aug 2012 10:58:56 +0800 Subject: [PATCH 34/35] [Property View] Fix bug: Add/Remove SelectMenu option refresh issue. --- src/css/builder.css | 2 +- src/js/views/property.js | 385 ++++++++++++++++++++++++--------------- 2 files changed, 236 insertions(+), 151 deletions(-) diff --git a/src/css/builder.css b/src/css/builder.css index 6ee74f20..f4609c10 100644 --- a/src/css/builder.css +++ b/src/css/builder.css @@ -929,7 +929,7 @@ div.propertyItems > div > * { display: table-cell; padding-bottom: 8px; } -table#selectOption { +table.selectTable { width: 100%; } div.propertyItems label[for] { diff --git a/src/js/views/property.js b/src/js/views/property.js index 2f3eaa45..08266c49 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -85,35 +85,73 @@ widget.refresh(event,widget); }, - _setProperty: function(property, value) { - var viewId = property + '-value'; - if (typeof(value) === 'boolean') { - this.element.find("#" + viewId).attr('checked', value); - } else { - this.element.find("#" + viewId).val(value); + _setProperty: function(property, propType, value) { + var element = this.element.find("#" + property + '-value'); + switch (propType) { + case "boolean": + element.attr('checked', value); + break; + default: + element.val(value); } }, + _redrawProperty: function(property, newElment) { + var element = this.element.find("#" + property + '-value'); + element.replaceWith(newElment); + }, + _modelUpdatedHandler: function(event, widget) { - var affectedWidget, id, value; + var affectedWidget, id, value, propType; widget = widget || this; if (event && event.type === "propertyChanged") { if (event.node.getType() !== 'Design') { id = event.property + '-value'; affectedWidget = widget.element.find('#' + id); - if (affectedWidget.attr('type') !== 'checkbox') { - value = affectedWidget.val(); - } else { - value = affectedWidget.attr('checked')?true:false; + propType = BWidget.getPropertyType(event.node.getType(), event.property); + + // Get value to for commparation + switch (propType) { + case "boolean": + value = affectedWidget.attr('checked')?true:false; + break; + case "record-array": + value = event.oldValue; // FIXME: oldValue can't passed here. + break; + default: + value = affectedWidget.val(); + break; } - if(event.newValue != value) { - affectedWidget[0].scrollIntoViewIfNeeded(); - if(typeof(event.newValue) === 'boolean') { - affectedWidget.effect('pulsate', { times:3 }, 200); - } else { - affectedWidget.effect('highlight', {}, 1000); - } - widget._setProperty(event.property, event.newValue); + + // Compare the newValue is equal with value, then return directly. + if (event.newValue == value) + return + + // Update ADM and apply effects. + switch (propType) { + case "boolean": + if (affectedWidget) { + affectedWidget[0].scrollIntoViewIfNeeded(); + affectedWidget.effect('pulsate', { times:3 }, 200); + } + widget._setProperty(event.property, propType, event.newValue); + break; + case "record-array": + value = event.oldValue; + // TODO: Do something with affectedWidget + // affectedWidget = event.element; + widget._redrawProperty( + event.property, + widget._generateRecordArraryTable(widget, event.node, event.property) + ); + break; + default: + if (affectedWidget) { + affectedWidget[0].scrollIntoViewIfNeeded(); + affectedWidget.effect('highlight', {}, 1000); + } + widget._setProperty(event.property, propType, event.newValue); + break; } return; } else if (event.property !== 'css') { @@ -138,6 +176,183 @@ return; }, + _generateSelectMenuOption: function(node, property, child, index, props) { + var changeCallback = function(event) { + var newValue, self = $(this); + props[property].children[index][event.data.key] = self.val(); + newValue = props[property]; + node.fireEvent("modelUpdated", { + type: "propertyChanged", + node: node, + property: property, + element: self, + newValue: newValue, + index: index + }); + }; + + if (!props) + props = node.getProperties(); + return $('').data('index', index) + .addClass("options") + .append('') + .children().eq(0) + .append('') + .children(':first') + .attr('src', "src/css/images/propertiesDragIconSmall.png") + .end() + .end().end() + .append('') + .children().eq(1) + .append('') + .children().eq(0) + .val(child.text) + .addClass('title optionInput') + .change({key: 'text'}, changeCallback) + .end().end() + .end().end() + .append('') + .children().eq(2) + .append('') + .children().eq(0) + .val(child.value) + .addClass('title optionInput') + .change({key: 'value'}, changeCallback) + .end().end() + .end().end() + .append('') + .children().eq(3) + .append('
                                    Delete
                                    ') + .children(':first') + // add delete option handler + .click(function(e) { + try { + var newValue, self = $(this); + // Generate ADM properties + index = self.parent().parent().data('index'); + props[property].children.splice(index, 1); + // Instead by draw, so comment following lines. + /* + // Remove the row element after clicked delete button + self.parent().parent().remove(); + */ + newValue = props[property]; + // Trigger the modelUpdated event. + node.fireEvent("modelUpdated", { + type: "propertyChanged", + node: node, + property: property, + element: self, + newValue: newValue, + index: index + }); + } + catch (err) { + console.error(err.message); + } + e.stopPropagation(); + return false; + }) + .end() + .end().end(); + }, + + _generateRecordArraryTable: function(widget, node, property, props) { + var child, table = $('') + .attr('id', property + '-value') + .addClass('selectTable') + .attr('cellspacing', '5'); + + if (!props) + props = node.getProperties(); + + $('') + .append('') + .append('') + .children().eq(1) + .addClass('title') + .end().end() + .append('') + .children().eq(2) + .addClass('title') + .end().end() + .append('') + .appendTo(table); + for (var i = 0; i< props[property].children.length; i++){ + child = props[property].children[i]; + table.append( + this._generateSelectMenuOption(node, property, child, i, props) + ); + } + + // add add items handler + $('') + .children(':first') + .addClass('rightLabel title') + .attr('id', 'addOptionItem') + .end() + .click(function(e) { + var newValue, self = $(this); + try { + var rowElement, index = props[property].children.length, + optionItem = { + 'text': 'Option', + 'value': 'Value' + }; + props[property].children.push(optionItem); + // Instead by draw, so comment following lines. + /* + rowElement = widget._generateSelectMenuOption( + node, property, optionItem, index, props + ); + */ + table.append(rowElement); + $(this).insertAfter(rowElement); + newValue = props[property]; + node.fireEvent("modelUpdated", { + type: "propertyChanged", + node: node, + property: property, + element: self, + newValue: newValue, + index: index + }); + } catch (err) { + console.error(err.message); + } + e.stopPropagation(); + return false; + }) + .appendTo(table); + + // make option sortable + table.sortable({ + axis: 'y', + items: '.options', + containment: table.find('tbody'), + start: function(event, ui) { + widget.origRowIndex = ui.item.index() - 1; + }, + stop: function(event, ui) { + var optionItem, curIndex = ui.item.index() - 1, + origIndex = widget.origRowIndex; + optionItem = props[property].children.splice(origIndex,1)[0]; + + props[property].children.splice(curIndex, 0, optionItem); + node.fireEvent("modelUpdated", { + type: "propertyChanged", + node: node, + property: property, + element: table, + newValue: props[property], + index: ui.item.index() + }); + } + }); + + return table; + }, + _showProperties: function(node) { var labelId, labelVal, valueId, valueVal, count, widget = this, type, i, child, index, propType, @@ -251,137 +466,7 @@ break; case "record-array": - $('
                                    Text Value
                                    + add item
                                    ') - .attr('id', 'selectOption') - .attr('cellspacing', '5') - .appendTo(value); - var selectOption = value.find('#selectOption'); - $('') - .append('') - .append('') - .children().eq(1) - .addClass('title') - .end().end() - .append('') - .children().eq(2) - .addClass('title') - .end().end() - .append('') - .appendTo(selectOption); - for (i = 0; i< props[p].children.length; i ++){ - child = props[p].children[i]; - $('').data('index', i) - .addClass("options") - .append('
                                    Text Value
                                    ') - .children().eq(0) - .append('') - .children(':first') - .attr('src', "src/css/images/propertiesDragIconSmall.png") - .end() - .end().end() - .append('') - .children().eq(1) - .append('') - .children().eq(0) - .val(child.text) - .addClass('title optionInput') - .change(node, function (event) { - index = $(this).parent().parent().data('index'); - props['options'].children[index].text = $(this).val(); - node.fireEvent("modelUpdated", - {type: "propertyChanged", - node: node, - property: 'options'}); - }) - .end().end() - .end().end() - .append('') - .children().eq(2) - .append('') - .children().eq(0) - .val(child.value) - .addClass('title optionInput') - .change(node, function (event) { - index = $(this).parent().parent().data('index'); - props['options'].children[index].value = $(this).val(); - node.fireEvent("modelUpdated", - {type: "propertyChanged", - node: node, - property: 'options'}); - }) - .end().end() - .end().end() - .append('') - .children().eq(3) - .append('
                                    Delete
                                    ') - .children(':first') - // add delete option handler - .click(function(e) { - try { - index = $(this).parent().parent().data('index'); - props['options'].children.splice(index, 1); - node.fireEvent("modelUpdated", - {type: "propertyChanged", - node: node, - property: 'options'}); - } - catch (err) { - console.error(err.message); - } - e.stopPropagation(); - return false; - }) - .end() - .end().end() - .appendTo(selectOption); - } - - // add add items handler - $('') - .children(':first') - .addClass('rightLabel title') - .attr('id', 'addOptionItem') - .end() - .appendTo(value); - value.find('#addOptionItem') - .click(function(e) { - try { - var optionItem = {}; - optionItem.text = "Option"; - optionItem.value = "Value"; - props['options'].children.push(optionItem); - node.fireEvent("modelUpdated", - {type: "propertyChanged", - node: node, - property: 'options'}); - } - catch (err) { - console.error(err.message); - } - e.stopPropagation(); - return false; - }); - - // make option sortable - value.find('#selectOption tbody').sortable({ - axis: 'y', - items: '.options', - containment: value.find('#selectOption tbody'), - start: function(event, ui) { - widget.origRowIndex = ui.item.index() - 1; - }, - stop: function(event, ui) { - var optionItem, curIndex = ui.item.index() - 1, - origIndex = widget.origRowIndex; - optionItem = props['options'].children.splice(origIndex,1)[0]; - - props['options'].children.splice(curIndex, 0, optionItem); - node.fireEvent("modelUpdated", - {type: "propertyChanged", - node: node, - property: 'options'}); - } - }); + value.append(this._generateRecordArraryTable(widget, node, p, props)); break; case "targetlist": container = node.getParent(); From f5fa8d95e7757c3b3bfc5f05cb3890961dd67fc3 Mon Sep 17 00:00:00 2001 From: John Chen Date: Fri, 31 Aug 2012 17:45:09 +0800 Subject: [PATCH 35/35] [Layout View] Fix RIB-19: Insertion line should not show up in illegal places --- src/js/composer.js | 2 +- src/js/widgets.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/composer.js b/src/js/composer.js index 36618177..6afb19a8 100644 --- a/src/js/composer.js +++ b/src/js/composer.js @@ -557,7 +557,7 @@ $(function() { // Collapsible's items are under .ui-collapsible-content '> .ui-collapsible-content > .adm-node,' + '> ul > li.adm-node,' + - '> div > .adm-node,' + + '> div.customHeader > .adm-node,' + '> *.orig-adm-node:not(.ui-header,.ui-content,.ui-footer)', start: function(event, ui){ trackOffsets('start: ',ui,$(this).data('sortable')); diff --git a/src/js/widgets.js b/src/js/widgets.js index de12b02d..57af6419 100644 --- a/src/js/widgets.js +++ b/src/js/widgets.js @@ -591,7 +591,11 @@ var BWidgetRegistry = { locator: '> div', cardinality: "N" } - ] + ], + delegate: function (domNode, admNode) { + $('> div', domNode).addClass('customHeader'); + return domNode; + }, }, /**