search.lzx
<library>
<class name="search">
<attribute name="sendsearch_del" value="$once{new LzDelegate( this, 'sendsearch') }"/>
<attribute name="lastsearchterm" value="${null}"/>
<method name="doSearch">
if ( !canvas.isopen ) {
this.sendsearch_del.unregisterAll();
var anm = canvas.setOpen(true);
this.sendsearch_del.register(anm, 'onstop' );
} else {
this.sendsearch();
}
</method>
<view width="88" name="title">
<stableborderlayout axis="x"/>
<view resource="../assets/search/title-left.gif"/>
<view resource="../assets/search/title-mid.gif" stretches="width"/>
<view resource="../assets/search/title-right.gif"/>
</view>
<view x="6" y="7" resource="../assets/search/title-text.gif"/>
<mybutton resource="transparent_rsc" width="${parent.width}" height="${parent.height}">
<handler name="onclick">
photoscontainer.lyt.setAttribute('currentpage', 1);
tls.resetOnLoad();
classroot.doSearch();
</handler>
</mybutton>
<view name="content" x="$once{parent.title.width}" width="${classroot.width - parent.title.x}" height="${parent.height - 1}">
<view resource="../assets/search/content-mid.gif" stretches="width" width="${parent.width}"/>
<view resource="../assets/search/content-right.gif" x="${parent.width - width}"/>
<inputtext name="txt" width="${parent.width}" height="${parent.height}" y="3">
<handler name="onkeyup" args="k">
if ( k == 13 ) { //return key
photoscontainer.lyt.setAttribute('currentpage', 1);
tls.resetOnLoad();
classroot.doSearch();
}
</handler>
</inputtext>
</view>
<method name="sendsearch" args="ignore=null">
var tags = this.getText();
Debug.info('tags', tags);
var argobj;
if (tags == "interesting") {
// Special search for interesting photos
argobj = [
{argname:"method",
argvalue:"flickr.interestingness.getList"}
]
} else if (tags=="recent") {
argobj = [
{argname:"method",
argvalue:"flickr.photos.getRecent"}
]
} else {
// search by tags
argobj = [
{argname:"method", argvalue:"flickr.photos.search"},
// Any Creative-Commons license (all include attribution)
{argname:"license", argvalue:"1,2,3,4,5,6"},
{argname:"tags", argvalue: tags},
{argname:"tag_mode", argvalue:"all"},
{argname:"sort", argvalue:"interestingness-desc"}
]
}
if(tags != this.lastsearchterm){
photoscontainer.lyt.setAttribute('currentpage', 1);
tls.resetOnLoad();
}
argobj.push({argname:"page", argvalue:Number(photoscontainer.lyt.currentpage)});
this.setAttribute('lastsearchterm', tags);
gDataMan.doFlickrRequest(photods, argobj);
//info('sendsearch', tags);
tls.displayPage();
</method>
<method name="searchInteresting">
this.setAttribute('text', "interesting");
this.sendsearch();
</method>
<setter name="text" args="t">
this.content.txt.setAttribute('text', t);
</setter>
<method name="getText">
return this.content.txt.text;
</method>
</class>
</library>